标签:使用 标签 ash str height 属性 标签设置 das 适合
什么时候用浮动——块级元素一行显示就使用浮动
浮动的特点——让元素脱标不占位置
什么时候清除浮动——父元素没有设置高度;父元素中所有的子元素都设置浮动
步骤:(1)在浮动元素后直接添加一个空div标签;(2)选中该div标签设置属性clear: both;
.clearfix::after {
content: "";
display: block;
clear: both;
height: 0;
line-height: 0;
/* 将该元素隐藏 */
visibility: hidden;
}
.clearfix {
/* 兼容IE写法 */
zoom: 1;
}
.clearfix:after,.clearfix:before{
content: "";
display: table;
}
.clearfix:after{
clear: both;
}
.clearfix{
*zoom: 1;
}
注意:如果使用overflow: hidden;清除浮动的时候,必须保证父元素中没有定位超出父元素的的元素
标签:使用 标签 ash str height 属性 标签设置 das 适合
原文地址:https://www.cnblogs.com/belongs-to-qinghua/p/11212324.html