1html body div.clear, 2html body span.clear 3{ 4 background: none; 5 border: 0; 6 clear: both; 7 display: block; 8 float: none; 9 font-size: 0; 10 margin: 0; 11 padding: 0; 12 overflow: hidden; 13 visibility: hidden; 14 width: 0; 15 height: 0; 16}
还有一种是
1.clearfix:after { 2 content: "020"; 3 display: block; 4 height: 0; 5 clear: both; 6} 7.clearfix { 8 zoom: 1; 9}
这个是优化版的清除浮动的样式,很值得推荐。
使用方法:通过在页面中添加<div class=”clear”></div> 或 <span class=”clear”> </span>来清除页面中的浮动。