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>