What is the current best solution to clear floats, such as "<div style='clear: both'></div>"?
I have used
<div style="clear: both"></div>
to clear the floats... and have seen cases where it is
<div style="clear: both; height: 1px; line-height: 1px"></div>
and have seen clearfix, and some with a hidden .
and make it the same color as the background. Now Compass and Blueprint also have a +clearfix
. What is the current best way to clear f开发者_如何学Goloats, now that probably we don't need to support IE 6?
Depending on the situation, I mostly use overflow or float the parent element. There is no best solution.
I actually like the method explained here: http://www.quirksmode.org/css/clearing.html. It get's away from adding an extra element to the html.
I have learned that
content: "";
display: table;
clear: both;
work with all browsers after IE 8+
I like clearfix. Read this too (which I didn't know about until just now): Everything you Know about Clearfix is Wrong.
精彩评论