一般情况下:
html body div.clear,
html body span.clear
{
background: none;
border: 0;
clear: both;
display: block;
float: none;
font-size: 0;
margin: 0;
padding: 0;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}使用方法:通过在页面中添加<div class=”clear”></div> 或 <span class=”clear”> </span>来清除页面中的浮动。
clear的定义当前比较热门的定义
.clear{clear: both;overflow: hidden;line-height: 0;height: 0;zoom:1}还有一种是
.clearfix:before,
.clearfix:after {content: ".";display: block;height: 0;overflow: hidden;visibility: hidden;}
.clearfix:after{clear: both}这个是优化版的清除浮动的样式,页面中不需要加任何东西,很值得推荐。