码迷,mamicode.com
首页 > 其他好文 > 详细

DIV 浮动存不占空间

时间:2016-05-17 17:55:03      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:

DIV 浮动存不占空间
比如
<div style="width:80px; border:1px solid #333">
<div style="float:left; height:50px; width:20px; background:#CCC"></div>
<div style="float:left; height:70px; width:50px; background:#000"></div>
</div>
你会发现因为里面的2个元素浮动,所以外面的DIV高度还是2px 2px是边框的。
浮动元素不占空间,
所以一般在下面加一个清除浮动就可以解决这个BUG
<div style="width:80px; border:1px solid #333">
<div style="float:left; height:50px; width:20px; background:#CCC"></div>
<div style="float:left; height:70px; width:50px; background:#000"></div>
<div style=" clear:both"></div>
</div>

DIV 浮动存不占空间

标签:

原文地址:http://www.cnblogs.com/allensun-193/p/5502390.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!