第一个元素的边距底部 10px 和第二个元素的边距顶部 10px,这个边距顶部只有在我把值大于边距底部时才有效,为什么



我不知道,但 li 元素边距顶部只有在它比 h2 元素的边距底部大时才有效,我想知道为什么?

<h2 style="padding:0px; margin:0; height:30px; line-height:30px; background-color:#FF0000; font-size:18px; font-family:Arial; margin-bottom:10px;">Test1</h2>
<ul style="list-style:none; padding:0; margin:0;">
<li style="height:50px; line-height:50px; background-color:#00FF00; font-size:12px; font-family:Arial; margin-top:10px;">Test2</li>
</ul>

谢谢。

你描述的听起来很像折叠的边距

我建议查看 http://reference.sitepoint.com/css/collapsingmargins 因为详细介绍了该问题以及解决方法。

最新更新