clear
.box{
width:100px;
height:100px;
background-color:red;
clear:left;
}
清除左浮动
.box{
width:100px;
height:100px;
background-color:red;
clear:right;
}
清除右浮动
- both 可以清除对它影响最大的浮动
- 可以解决高度塌陷
.clearfix:after
.clearfix:after{
content:' ';
display:hidden;
clear:both;
}
谁塌陷就加上clearfix