【发布时间】:2017-09-03 11:01:03
【问题描述】:
我在 <div> 元素内为子 <p> 提供边距,但它正在移动 div 元素本身。我想将段落下移到任意值。我知道我们可以为父元素提供填充,但是呢?
在这里,使用此示例代码...尝试更改.square p 边距属性。
*{
margin: 20px auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.square {
width: 100px;
height: 100px;
background: #f56;
} .square p {
margin: 50px auto;
}
<div class="square"><p>Hi</p></div>
不应该是相对于父元素的吗?
【问题讨论】: