Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

IMHO 'CSS positioning 101' will not be complete without mentioning the (in)famous float property.


Float's aren't that bad, other than the fact that the parent element will suddenly lose any inherent height if all child elements have floats.

I've got a few friends who extol the virtues of inline-block, but my clients have viewer demographics of 70% ie6.

Hack here, if you really want inline-block with ie6: http://www.aaronrussell.co.uk/blog/cross-browser-support-for...


If you set overflow to auto on the parent element it will retain its height.


You also need to set the width. Explanation here

http://www.quirksmode.org/css/clearing.html


Quirksmode does an excelent job explaining this. And covering ie/chrome/safari bugs adds extra credit.


I usually put a <div style="clear:both"></div> after the floats to fix that.


I just tested it because it sounded so beautiful but that does not work in IE6 unfortunately.


It has worked for me. Does the container have hasLayout?


Excellent. Thanks for the tip!


In general are floats now out of favor, and one should one of the layout methods listed on this page?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: