这里有多种方法可以展开垂直PARENT边距,但没有关于展开相邻元素垂直边距的内容。我找到的唯一解决方案是在这个答案中(2009年):
<div style="overflow: hidden; height: 0px; width: 0px;"> </div>
自从那时以来已经过去了近7年。是否有更好的方法来实现这个(可能使用一些CSS3)?
基本上,假设您有:http://jsfiddle.net/ok2u3o3c/
<div class="one"></div>
<div class="two"></div>
div {
width: 300px;
height: 200px;
}
.one {
margin-bottom: 10px;
background-color: blue;
}
.two {
margin-top: 20px;
background-color: red;
}
在这两个框之间使距离为30px的最优雅的方法是什么(第一个边距应该为10px,不会塌陷)?