首页 > Web开发 > 详细

css清除浮动的五种常用方法

时间:2017-05-14 17:45:12      阅读:317      评论:0      收藏:0      [点我收藏+]
  1. 父级div定义固定高度height
  2. 结尾处加空div标签 clear:both 
    <style type="text/css"> 
    ...
    /*清除浮动代码*/ 
    .clearfloat{clear:both} 
    </style> 
    <div class="box"> 
        <div class="float-left">Left</div> 
        <div class="float-right">Right</div> 
        <div class="clearfloat"></div> 
    </div> 
  3. 父级div定义 伪类:after 和 zoom
    <style type="text/css"> 
    ...
    /*清除浮动代码*/ 
    .box:after{display:block;clear:both;content:"";visibility:hidden;height:0} 
    .box{zoom:1}  /*IE兼容*/
    </style> 
    <div class="box"> 
        <div class="float-left">Left</div> 
        <div class="float-right">Right</div> 
    </div> 

     

  4. 父级div定义 overflow:hidden
  5. 父级div 也一起浮动 

css清除浮动的五种常用方法

原文:http://www.cnblogs.com/fangdong/p/6852984.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!