Compensating for double margins in Internet Explorer

Internet Explorer sometimes inserts double margins in layouts when you float items. Here's how to work around it.

Here's an example of how it can look:

Internet Explorer float bug

The extra spacing (marked by the red rectangle) appears in Internet Explorer when you float an image to the right (blue rectangle) inside the content area.

The workaround is to set the height to an impossible 1%, as explained in the invisible text bug in Internet Explorer article.

In Plone 2.1, we introduced a helper class that lets you do this. It's located in ploneIEFixes.css, and looks like this:

  /* Fix for IE float bug */
  * html .visualIEFloatFix {
    height: 0.1%;
  }

(If you run an earlier version of Plone, just cut and paste the above into your CSS file.)

So, in this case, the solution is to wrap the area directly beneath the headline Available downloads (text + image) in a div with this class:

  <div class="visualIEFloatFix">

The extra spacing on the left side will now disappear, and the page will look identical to the way it does in other browsers.

Thanks to Michael Zeltner in providing assistance on how to solve this problem.

-- Alexander Limi

Related content

Fixing invisible or disappearing text and double margins in Internet Explorer
Internet Explorer has a very serious bug when calculating the height of floating elements, which can cause elements to disappear. Here's a simple way to work around it in any layout, with a special convenience class for Plone - although the approach is valid for any CSS layout.

there is more than one way to do it

Posted by Moritz Stoltenburg at Mar 12, 2007 04:07 PM
There is a much easier way to solve this bug.

Add 'display: inline;' to the floated element and the double margin in IE disappears. This is by the way harmless CSS for all other browsers because according to W3C for floating elements the 'display' is ignored, unless it has the value 'none'.

found at: http://www.positioniseverything.net/[…]/doubled-margin.html

and it works :)