.clear 万能清除浮动(clearfix:after)


一般情况下:


复制代码
代码如下:

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;
}

还有一种是


复制代码
代码如下:

.clearfix:after {
content: "020";
display: block;
height: 0;
clear: both;
}
.clearfix {
zoom: 1;
}

这个是优化版的清除浮动的样式,很值得推荐。

使用方法:通过在页面中添加<div class=”clear”></div> 或 <span class=”clear”> </span>来清除页面中的浮动。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3