css清除浮动(推荐)
为什么要清除浮动呢?
---因为子元素设置浮动后,父级元素不能自动被撑开,影响页面布局。
解决方法有很多种,最为推荐一种,其他不多说了,一种足够。
<div class='parent'>
<div class="son"></div>
</div>
.son{
width:200px;
height:100px;
}
//清除浮动
.parent:after{
content:"";
height:0;
line-height:0;
display:block;
visibility:hidden;
clear:both;
}
//兼容ie
.parent{
zoom:1;
}
本文来自博客园,作者:青石小巷,转载请注明原文链接:https://www.cnblogs.com/lgnblog/p/13292806.html

浙公网安备 33010602011771号