6 ms·
I usually use overflow:hidden on containers, what are the pro's and cons of this compared to clearfix?
by dutchbrit 10y ago
I usually use overflow:hidden on containers, what are the pro's and cons of this compared to clearfix?
- martin-adams 10y agoInteresting, I did not know that overflow:hidden resized the parent container to the floated elements. It looks like the difference may be some legacy IE6 thing.
- thomasahle 10y agoWhy doesn't it just crop the element to fit, as with everything else?
- martin-adams 10y agoThat was my immediate thought then I tried it out. I suspect it's to do with causing some hasLayout which recalculates the content dimensions.
- SippinLean 10y agohasLayout is IE-only and dead since IE7
- rossriley 10y agoYou can set overflow to visible too, just setting overflow to non-auto is enough to trigger it.
- SippinLean 10y agoNo, just auto, hidden, overlay, and scroll. Visible will not trigger the clearfix.
- deleted 10y ago[deleted]
- deanclatworthy 10y agoThis is my go-to fix also. Have used it for years with no side effects or bugs as a result.
- rimantas 10y agoAlways used that one and could not care less about clearfix.
- SippinLean 10y agoIn case you want elements to appear outside the parent, like a dropdown menu. In ancient times some browsers required setting a width or height as well.
- ryanSrich 10y agoThis will cut off larger diffuse drop shadows, which is one immediate downside I can think of.