推荐几种好用的清除浮动方法:
方法1:
.clearfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; } .clearfix{*+height:1%;}
方法2:
.clearfix:after { content:"200B"; display:block; height:0; clear:both; } .clearfix {*zoom:1;}/*IE/7/6 */ /* content:"200B";这个参数,Unicode字符里有一个“零宽度空格”,即 U+200B,代替原来的“.”,可以缩减代码量。而且不再使用visibility:hidden。 */
方法3:
.clearfix { overflow:auto; _height:1%; }
方法4:
.clearfix { overflow:hidden; _zoom:1; }