DIV 浮动存不占空间

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>

转载于:https://www.cnblogs.com/allensun-193/p/5502390.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值