清除浮动:clear-常用clear:both;或者clear:left;clear:right;
同时设置width:100%(或固定宽度)+overflow:hidden;
当父包含块缩成一条时,用clear:both方法清除浮动无效。它一般用于紧邻后面的元素的清除浮动。
列如:
<html>
<head>
<head>
<style>
#wrap{ background:#00c;margin:0 auto;width:960px; clear:both;}//有效的清除是overfloat:hidden;
#left{width:800px; height:120px;background:#123456;float:left;}
#right{width:120px; height:120px;background:#000;float:right;}
</style>
<body>
<div id =”wrap”>
<div id=”left”>
</div>
<div id=”right”>
</div>
</div>
<div id=”footer”>12134</div>
</body>
</html>
设置元素浮动时,紧邻其后的元素会上移,并紧挨着其作则显示。