首页 > 其他 > 详细

清除浮动之父级div定义伪类:after和zoom

时间:2019-10-14 14:37:42      阅读:123      评论:0      收藏:0      [点我收藏+]

这是比较常用的一种清除浮动的方法,各大网站都在采用:

<!Doctype html>
<html>
<head></head>
<body>
<style type="text/css"> 
   .div1{background:#333;border:1px solid red;}
   .div2{background:#888;border:1px solid red;height:100px;margin-top:10px}
   
   .left{float:left;width:20%;height:200px;background:#fff}
   .right{float:right;width:30%;height:80px;background:#fff}
   
   /*清除浮动代码*/
   .clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0}
   .clearfloat{zoom:1}
   </style> 
<div class="div1 clearfloat"> 
<div class="left">Left</div> 
<div class="right">Right</div> 
</div>
<div class="div2">
   div2
   </div>
</body>
</html>

 

清除浮动之父级div定义伪类:after和zoom

原文:https://www.cnblogs.com/xxySsm/p/11671042.html

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