正如您在this picture中看到的,我在橙色div
内部看到一个绿色的div
,没有上边框。橙色div
有一个30px
顶部边距,但它也推动了绿色div
下降。当然,添加顶部边框可以解决这个问题,但我需要绿色div
顶部无边框。我能做什么?CSS:父母没有边框时的边际保留
.body {
\t border: 1px solid black;
\t border-top: none;
\t border-bottom: none;
\t width: 120px;
\t height: 112px;
\t background-color: lightgreen;
}
.body .container {
\t background-color: orange;
\t height: 50px;
\t width: 50%;
\t margin-top: 30px;
}
<div class="header">Top</div>
<div class="body">
\t <div class="container">Box</div>
</div>
<div class="foot">Bottom</div>
感谢
你能详细说明所需的效果吗?您是否希望橙色容器中的文本显示为距顶部30像素,还是希望橙色容器的顶部显示为绿色容器顶部下方30像素? – Mayo 2009-09-08 15:45:36
相关问题:http://stackoverflow.com/questions/315738/unexpected-margin-with-very-simple-html – mercator 2009-09-08 15:59:56
可能更适合http://doctype.com/ – Nobody 2010-08-03 10:40:18