问题描述
在此处显示边距折叠。
.ct1{
background: red;
margin:40px;
border:1px solid;width:100%;
}
.ct2{
background: pink;
margin:40px;
border:1px solid;width:100%;
}
<div class="ctbox">
<div class="ct1">first</div>
<div class="ct2">second</div>
</div>
两个div ct1
和ct2
之间将出现边距折叠,它们之间的距离不是40px + 40px = 80px,而不是40px。
现在我在display:inline-block;
或ct1
中添加一个css语句ct2
,它们之间的距离将变为80px,边距消失。为什么display:inline-block;
可以防止边距崩溃?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)