1、使用after伪对象清除浮动
    这种方法用于非IE浏览器。参考以下例子需注意几点。一、必须给需要清除浮动元素的伪对象中设置height:0,这样该元素不会比实际高出几像素;二、content属性是必须的,content属性的值设为”.”,但发现为空亦是可以的。
<style type=”text/css”> 
<!– 
    *{margin:0;padding:0;} 
    body{font:36px bold; color:#F00; text-align:center;} 
    #layout{background:#FF9;} 
    #layout:after{display:block;clear:both;content:”";visibility:hidden;height:0;} 
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} 
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} 
–> 
</style>
<div id=”layout”> 
    <div id=”left”>Left</div> 
    <div id=”right”>Right</div> 
    <p class=”clr”> 
</div>
2、空标签清除浮动
  空标签用div标签,也用P标签。也有很多人用<hr>,需要另外为其清除边框,理论上可以用任何标签。
  此方法是在需要清除浮动的父级元素的所有浮动元素后再添加一个标签清楚浮动,CSS代码:clear:both。但是增加了无意义的结构元素。
<style type=”text/css”> 
<!– 
    *{margin:0;padding:0;} 
    body{font:36px bold; color:#F00; text-align:center;} 
    #layout{background:#FF9;} 
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} 
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} 
    .clr{clear:both;} 
–> 
</style>
3、使用overflow属性
此方法是只需在需要清除浮动的元素中定义CSS属性:overflow:auto,即可!”zoom:1″用于兼容IE6。
<style type=”text/css”> 
<!– 
    *{margin:0;padding:0;} 
    body{font:36px bold; color:#F00; text-align:center;} 
    #layout{background:#FF9;overflow:auto;zoom:1;} 
    #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} 
    #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} 
–> 
</style>