在受到浮动影响的元素前面,添加一个空div,给空div添加样式:clear:both
<style>
.box1{
width: 100px;
height: 100px;
background-color: red;
float:left;
}
.box2{
width: 200px;
height: 200px;
background-color: green;
}
.clearFix{
clear: both;
}
</style>
<div class="box1">box1</div>
<div class="clearFix"></div>
<div class="box2">box2</div>