这是我的html:
<div class='parentDiv'>
<div class='childDiv'></div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的CSS:
.parentDiv {
margin-top: 200px;
width: 700px;
height: 800px;
background-color: red;
}
.childDiv {
background-color: green;
width: 50px;
height: 50px;
margin-top: 22px;
}
Run Code Online (Sandbox Code Playgroud)
小提琴:http://jsfiddle.net/1whywvpa/
childDiv为何无法获得22px的页边空白?如果像素大于已经提供给parentDiv的200像素,则它只会获得页边空白。有什么办法可以使childDiv相对于parentDiv获得22px的父级div,而无需进行某种类型的“给父div一个1px的填充”黑客?
| 归档时间: |
|
| 查看次数: |
8041 次 |
| 最近记录: |