views:

45

answers:

3

Hello,

If there are floated elements in a parent element, they parent element looses its shape or has no height. How to deal with this problem?

Thanks

+1  A: 

On the parent, do a:

 style="overflow: auto"
Pekka
that won't work in IE6
Faisal Deedar
@Faisal `overflow: visible` has problems in IE. Auto should not. Anyway, clearfix is a good idea as well.
Pekka
@Pekka: I just tried with overflow auto, did not work in IE6 and when i added zoom:1px then it worked fine as suggested by vermutt. I could show my code if you say, it did not work in IE6. Thanks anyways.
Faisal Deedar
+3  A: 

The solution to that is using clearfix class.

Sarfraz
hmmmmm, seems clearfix is better solution yet. Thanks
Faisal Deedar
@Faisal Deedar: thank you :)
Sarfraz
+1  A: 

Basically you have to wrap floated elements with a block that has a clearfix hack applied. Read more here: http://www.webtoolkit.info/css-clearfix.html

For IE<7 you would also use zoom:1;