<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>18013</bug_id>
          
          <creation_ts>2008-03-22 06:19:28 -0700</creation_ts>
          <short_desc>Margin auto: difference between centered divs and images in body background</short_desc>
          <delta_ts>2011-07-15 15:48:29 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://www.xs4all.nl/~jjj/webkit_margin_auto</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jan Boeijink">jjj</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dominicc</cc>
    
    <cc>efc</cc>
    
    <cc>mupo</cc>
    
    <cc>scottbruin</cc>
    
    <cc>stevethepocket</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>74799</commentid>
    <comment_count>0</comment_count>
    <who name="Jan Boeijink">jjj</who>
    <bug_when>2008-03-22 06:19:28 -0700</bug_when>
    <thetext>Please follow the link, this makes it clear immediately. 
We have a horizontally centered div and a centered image in the body background. When scaling the window smaller than the background image width, a 1px gap becomes visible. Apparently when the image is larger than the window, it&apos;s not perfectly centered? This works perfectly in Firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74800</commentid>
    <comment_count>1</comment_count>
    <who name="Jan Boeijink">jjj</who>
    <bug_when>2008-03-22 06:25:22 -0700</bug_when>
    <thetext>After posting the bug, I noticed that while the gap is not visible in FF, the background image is still moved when making the window smaller, not similar to Safari. I&apos;m not sure which behaviour is better.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116710</commentid>
    <comment_count>2</comment_count>
    <who name="Scott Hulbert">scottbruin</who>
    <bug_when>2009-04-06 20:55:12 -0700</bug_when>
    <thetext>I have found this bug troubling and it is widely complained about online with no known solution. 

The issue seems to stem from background-position: center [y]; rounding differently than margin: [y] auto; when a window is an odd width. This can cause serious visual alignment issues unless the same centering method is used for the entire page.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>317865</commentid>
    <comment_count>3</comment_count>
    <who name="">stevethepocket</who>
    <bug_when>2010-12-06 15:14:18 -0800</bug_when>
    <thetext>I am using Windows 7 and have noticed this bug in both Chrome 8.0.552.215 and Safari 5.0.3. I downloaded the latest WebKit build (r73302) as per the recommendation and saw that it still has the problem. Curiously, my boss, who has a Mac, said over Skype that he&apos;s not experiencing it.

A lot of developers, including myself, use a combination of background-align:center and margin:auto for centered backgrounds, so getting them to play nice with each other is fairly important. To the point of being worth fixing in an automatic patch rather than waiting for Safari 6.

Curiously, this only happens when the window is wider than the background image. They both scale correctly from that point down. If you visit the link, shrink the window down to be narrower than the background, and start stretching the right edge of the window one pixel at a time, you can see the background uncover one pixel, then move right one pixel, then uncover, move, uncover, move, then move again when you get to the 1025-pixel mark. Very odd.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>335515</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2011-01-17 14:13:54 -0800</bug_when>
    <thetext>&lt;rdar://problem/8875207&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>344495</commentid>
    <comment_count>5</comment_count>
    <who name="Eric Celeste">efc</who>
    <bug_when>2011-02-02 19:56:22 -0800</bug_when>
    <thetext>There is a nice description of this bug at http://www.hackvalue.nl/en/article/85/off-by-one_errors_in_background_placement_in_web_browsers with an even simpler example http://www.hackvalue.nl/bug.html available.

I have noticed that this bug can also result in a one pixel VERTICAL offset when using Mobile Safari (AppleWebKit/533.17.9) on iOS.

Using a wrapper div with the background-position exhibits the bug (both horizontal and vertical):


   background-image: url(images/rea-back.png);
   background-position: center top;

Using a wrapper div with the margin auto resolves the bug (both horizontal and vertical):

   background-image: url(images/rea-back.png);
   width: 1020px;
   margin: 0px auto;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>344497</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Celeste">efc</who>
    <bug_when>2011-02-02 20:01:40 -0800</bug_when>
    <thetext>By the way, this seems to be the same bug reported as Bug 14956.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>427361</commentid>
    <comment_count>7</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2011-06-25 07:45:59 -0700</bug_when>
    <thetext>*** Bug 14956 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>438034</commentid>
    <comment_count>8</comment_count>
      <attachid>101059</attachid>
    <who name="Ian Storm Taylor">ian</who>
    <bug_when>2011-07-15 15:48:29 -0700</bug_when>
    <thetext>Created attachment 101059
A simpler test case that makes the problem more obvious.

Why has this still not been fixed after being reported 3 years ago?

All other rendering engines handle this case appropriately.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>101059</attachid>
            <date>2011-07-15 15:48:29 -0700</date>
            <delta_ts>2011-07-15 15:48:29 -0700</delta_ts>
            <desc>A simpler test case that makes the problem more obvious.</desc>
            <filename>url.txt</filename>
            <type>text/plain</type>
            <size>58</size>
            <attacher name="Ian Storm Taylor">ian</attacher>
            
              <data encoding="base64">aHR0cDovL2lhbnN0b3JtdGF5bG9yLmNvbS9leHBlcmltZW50cy9fY3NzLWNlbnRlcmluZy10ZXN0
Lw==
</data>

          </attachment>
      

    </bug>

</bugzilla>