{"id":151,"date":"2009-07-19T09:17:31","date_gmt":"2009-07-19T08:17:31","guid":{"rendered":"http:\/\/www.simonbattersby.com\/blog\/?page_id=151"},"modified":"2012-05-29T11:43:43","modified_gmt":"2012-05-29T10:43:43","slug":"overflowauto-and-gaps-in-chrome-safari-and-opera","status":"publish","type":"page","link":"https:\/\/www.simonbattersby.com\/blog\/overflowauto-and-gaps-in-chrome-safari-and-opera\/","title":{"rendered":"Overflow:auto and gaps in Chrome, Safari and Opera"},"content":{"rendered":"<p>I hit this issue building this website and can&#8217;t find much about it anywhere else.<\/p>\r\n\r\n<p>This manifests itself where a floated column of fixed width is adjacent to a fluid column to which <code>overflow:auto<\/code> (commonly used to clear floats) has been applied. So my example html:<\/p>\r\n\r\n<pre>&lt;div id=\"left\"&gt;&lt;\/div&gt;\r\n&lt;div id=\"right\"&gt;&lt;\/div&gt;<\/pre>\r\n&#8230;complex stuff&#8230;. and my css:\r\n<pre>#left{float:left;width:200px;height:100px;background-color:red}\r\n#right{margin-left:200px;height:100px;background-color:blue;overflow:auto}<\/pre>\r\n\r\n<p>Now in IE6 (if we&#8217;ve <a title=\"Fixing the IE6 3px issue\" href=\"\/blog\/ie6-and-the-3px-bug\/\">fixed the 3px issue<\/a>), IE7, IE8, FF and Opera 11 the page looks fine:<\/p>\r\n\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/guides\/overflow_auto\/firefox.jpg\" alt=\"Test page in FF3 - no gaps\" width=\"525\" height=\"97\" \/>\r\n\r\n<p>But in Chrome and Safari 4\/5 it looks like this, with a big gap on the right:<\/p>\r\n\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/guides\/overflow_auto\/safari.jpg\" alt=\"Test page in Safari 4 - gap on the right\" width=\"525\" height=\"88\" \/>\r\n\r\n<p>And in Opera 9 and 10 the gap&#8217;s on the left like this:<\/p>\r\n\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/guides\/overflow_auto\/opera.jpg\" alt=\"Test page in Opera9 - gap on the left\" width=\"525\" height=\"100\" \/>\r\n\r\n<p>It seems that Safari, plus older versions of Opera and Chrome introduce a gap equivalent to the width of the floated element, #left. If #right is assigned a fixed width, the problem goes away, there&#8217;s no gap. However, removing overflow:auto and using another method of clearing floats is the only other solution if I want #right to remain fluid. Interesting that this appears to have been &#8220;fixed&#8221; in Opera 11, and somewhere between Chrome 3 and Chrome 19.<\/p>\r\n\r\n<p>I&#8217;m not sure which browser is correct here, or even if there is a &#8220;correct&#8221;.<\/p>\r\n\r\n<p>Do please send me a comment if you have anything to contribute to this.<\/p>\r\n\r\n<p>I&#8217;ve created a demo page <a title=\"Demo page for overflow auto inconsistencies\" href=\"\/demos\/overflowauto_demo.htm\">here<\/a>, if you want to see this for yourself.<\/p>\r\n\r\n<p>Thanks to Benkus for his <a href=\"#comment-2242\">comment<\/a> suggesting including an additional div within the element &#8211; so the outer div has the fluid width and the inner div has overflow:auto &#8211; you can see this on the demo as well<\/p>","protected":false},"excerpt":{"rendered":"<p>I hit this issue building this website and can&#8217;t find much about it anywhere else. This manifests itself where a floated column of fixed width is adjacent to a fluid column to which overflow:auto (commonly used to clear floats) has been applied. So my example html: &lt;div id=&#8221;left&#8221;&gt;&lt;\/div&gt; &lt;div id=&#8221;right&#8221;&gt;&lt;\/div&gt; &#8230;complex stuff&#8230;. and my css: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-151","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":0,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/151\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/media?parent=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}