
[英]Why are two elements only 50 pixels apart when the top element has a 50px margin-bottom and the bottom element has a 50px margin-top?
[英]First element with margin-bottom 10px and second element with margin-top 10px, this margin-top only work if i put value large than margin-bottom, why?
我不知道但是li元素margin-top只有在h2元素的margin-bottom大的情况下才能工作,我想知道为什么?
<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,因为问题已经详细介绍,并提供修复方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.