清除浮动最好的两种方式
用after伪类清除浮动
.clearfix:after{
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
//为兼容IE6,IE7,因为ie6,ie7不能用after伪类。加上下面代码
.clearfix{zoom:1}
用clear方式清除浮动
万能的清除浮动的样式:调用方式:
<div class="clear"></div>
清除浮动的样式要写在浮动的下一个兄弟元素里
html body div.clear,
html body span.clear{
background: none;
border: 0;
clear: both;
float: none;
font-size: 0;
margin: 0;
padding: 0;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}