【发布时间】:2011-09-28 15:13:24
【问题描述】:
获取此 HTML:
<div>
<div class="block">Hello</div>
<div class="block">Hello</div>
<div class="block">Hello</div>
<div class="block">Hello</div>
</div>
使用配套的 CSS:
div.block
{
float: left;
width: 100px;
height: 100px;
margin: 1px;
background: red;
}
这样做的结果是四个块,它们之间有 2 像素 的空间(距左侧块的右边距 1px,距右边块的左边距 1px)。
有没有办法可以达到与边框折叠类似的效果? IE。我希望相邻块之间只有一个像素的边距。
这是我经常遇到的更复杂情况的一个基本示例,我不想通过任何类似于仅将 margin-left 设置为 1 像素等的方法来绕过它。
【问题讨论】: