【发布时间】:2014-06-07 02:30:26
【问题描述】:
我可能只是不了解基本的 CSS 和 HTML,但这让我非常恼火。我在“内容” div 中有一个“测试” div,我想要一个 10 像素的边距顶部而不是填充,因为我想将整个“测试”元素向下推 10 像素。 margin-top 似乎是答案,但它不是从父元素推送,而是从页面顶部推送。
* {
margin: 0px;
padding: 0px;
font-family: 'Source Sans Pro', sans-serif;
}
body {
background-color: #336699;
}
a {
text-decoration: none;
color: #336699;
}
#container {
margin: 0px auto;
width: 1000px;
}
#content {
background-color: rgba(255, 255, 255, 1);
margin-top: 50px;
height: 500px;
border-radius: 10px;
}
#test {
background-color: red;
margin-top: 10px;
}
<div id="container">
<div id="content">
<div id="test">
test
</div>
</div>
</div>
【问题讨论】: