4 ms·
IMHO 'CSS positioning 101' will not be complete without mentioning the (in)famous float property.
by niyazpk 16y ago
IMHO 'CSS positioning 101' will not be complete without mentioning the (in)famous float property.
- deleted 16y ago[deleted]
- sudont 16y agoFloat'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-inline-block/ http://www.aaronrussell.co.uk/blog/cross-browser-support-for...
- oneplusone 16y agoIf you set overflow to auto on the parent element it will retain its height.
- sudont 16y agoExcellent. Thanks for the tip!
- mikeklaas 16y agoI usually put a <div style="clear:both"></div> after the floats to fix that.
- sosuke 16y agoI just tested it because it sounded so beautiful but that does not work in IE6 unfortunately.
- isleyaardvark 16y agoIt has worked for me. Does the container have hasLayout?
- boundlessdreamz 16y agoYou also need to set the width. Explanation here http://www.quirksmode.org/css/clearing.html http://www.quirksmode.org/css/clearing.html
- DanielRibeiro 16y agoQuirksmode does an excelent job explaining this. And covering ie/chrome/safari bugs adds extra credit.
- kenjackson 16y agoIn general are floats now out of favor, and one should one of the layout methods listed on this page?