1
如果您在第一个框(red_box)上放置了一个保证金顶部,它将拉动或影响包含框(容器)。为什么?HTML和CSS ---保证金问题
.red_box {
background-color: red;
margin-top: 10px;
margin-right: 20px;
margin-bottom: 20px;`
margin-left: 40px;
height: 100px;
width: 300px
}
.green_box {
background-color: green;
margin-top: 40px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 40px;
height: 100px;
width: 300px
}
.container {
width: 500px;
height: 500px;
background-color: yellow;
}
<div class="container">
<div class="red_box">
red box
</div>
<div class="green_box">
green box
</div>
</div>