<style>
.box{border:5px solid #000; width:500px;}
.left{ float:left; background:#00f; height:100px; width:100px;}
.right{ float:right; background:#0ff; height:200px; width:200px;}
</style>
<body>
<div class="box">
<div class="left"></div>
<div class="right"></div>
</div>
</body>

1.overflow:hidden
<style>
.box{border:5px solid #000; width:500px;overflow:hidden;}
.left{ float:left; background:#00f; height:100px; width:100px;}
.right{ float:right; background:#0ff; height:200px; width:200px;}
</style>
<body>
<div class="box">
<div class="left"></div>
<div class="right"></div>
</div>
</body>

2.clear:both 在最后面加一个空元素
<style>
.box{border:5px solid #000; width:500px;}
.left{ float:left; background:#00f; height:100px; width:100px;}
.right{ float:right; background:#0ff; height:200px; width:200px;}
.clearx{ clear:both;}
</style>
<body>
<div class="box">
<div class="left"></div>
<div class="right"></div>
<div class="clearx"></div>
</div>
</body>
3.利用伪元素 :after
<style>
.box{border:5px solid #000; width:500px;}
.left{ float:left; background:#00f; height:100px; width:100px;}
.right{ float:right; background:#0ff; height:200px; width:200px;}
.clearfx::after{ content: '';display: block;clear: both;}
</style>
<body>
<div class="box clearx">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
4.display:table
<style>
.box{border:5px solid #000; width:500px;display:table;}
.left{ float:left; background:#00f; height:100px; width:100px;}
.right{ float:right; background:#0ff; height:200px; width:200px;}
</style>
<body>
<div class="box">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
5.父级一起浮动
<style>
.box{border:5px solid #000; width:500px;float:left;}
.left{ float:left; background:#00f; height:100px; width:100px;}
.right{ float:right; background:#0ff; height:200px; width:200px;}
</style>
<body>
<div class="box">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
6.overflow:auto