【发布时间】:2016-01-19 17:35:21
【问题描述】:
正如您在this picture 中看到的,我在绿色div 中有一个橙色div,没有顶部边框。橙色的div 有一个30px 的上边距,但它也将绿色的div 向下推。当然,添加顶部边框可以解决问题,但我需要绿色的div 顶部无边框。我能做什么?
.body {
border: 1px solid black;
border-top: none;
border-bottom: none;
width: 120px;
height: 112px;
background-color: lightgreen;
}
.body .container {
background-color: orange;
height: 50px;
width: 50%;
margin-top: 30px;
}
<div class="header">Top</div>
<div class="body">
<div class="container">Box</div>
</div>
<div class="foot">Bottom</div>
谢谢
【问题讨论】:
-
你能详细说明想要的效果吗?您希望橙色容器中的文本显示在距顶部 30 像素的位置,还是希望橙色容器的顶部显示在距绿色容器顶部 30 像素的位置?
-
可能更适合doctype.com
标签: css border margin collapse