If a series of floats are placed inside a container with no specified width or height- and the floats' width exceeds the natural width of the container, the container will not expand vertically to fit the floats— and the floats will extend outside the container.
Specify zoom: 1 for the container (inside a conditional comment).
If a series of floats followed by a clearing div is placed inside a container with no specified width or height, and the floats' width exceeds the natural width of the container, the container will not expand vertically to fit the floats—and the floats will extend outside the container in Windows/Internet Explorer 6 and earlier. Other potential pitfalls include horizontal scrollbars appearing in the page when the window is resized to alternate widths.
This bug was originally reported and documented by Big John Gallant and Holly Bergevin at positioniseverything.net. (Read original article)
The old (pre-IE7) solution for this bug, and several others, was the Holly Hack. However, the Holly Hack relies on buggy behavior that is no longer present in Internet Explorer 7 -- and using it can cause things to go a bit haywire. Instead, use an Internet Explorer Conditional Comment (IECC) to apply zoom: 1 to the container in all versions of Internet Explorer. This will give the container the "layout" it needs to keep the floats from escaping.
<!--[if IE]>
<style type="text/css">
#containerID { zoom: 1;}
</style>
<![endif]-->
Text ID: ESCAPING_FLOATS
To add a comment, please Log in.
Post updated
by LoriHC (Dreamweaver Team) on July 14, 2007
Hi rich30
Thanks for the prodding -- I've been meaning to update the posts that mention the Holly Hack as the solution. I've just updated this one and will update others shortly.
Use conditional comments instead of hack
by rich30 on July 10, 2007
As this only affects IE (I've seen this in IE7 as well) try a conditional comment instead of a hack.
Put this in the head of your document e.g.
<!--[if IE]><style type="text/css">
#featuredProducts {height:1%;}lt;/style>
<![endif]-->
I have to agree
by SRL_Bam_Bam on June 4, 2007
I have to agree with sbstash on this issue, the only way to resolve it is to add a width/height to your container.
Why hack?
by sbstash on February 5, 2007
What is the point of using this hack? Honestly, hacks should really be avoided at all costs. How often does a designer place a series of floats inside a container w/o specifying any widths or heights? Why would you even consider doing this? This seems really obscure, especially considering IE 5 is still listed on the original post.
Here's a solution: apply a width/height to your floats.