我需要确保两个元素始终相隔 100 像素。我的代码没有错误,但由于某种原因,P 标签上的 margin-bottom 设置为 50 像素,而其下方 DIV 上的 margin-top 也设置为 50 像素。
它们总共只有 50 像素,而不是总共 100 像素。有人可以解释一下吗?我的页面上没有任何浮动,所以这不是由于清算问题。所有 html 和 css 都已经过验证。
这发生在最新版本的 Chrome 和 FIrefox 3.6 中。
这是我的代码示例:
#content p {
margin-bottom: 50px;
}
#content #posted {
border-top: 1px dotted #ccc;
line-height: 20px;
margin-top: 50px;
}