I have an issue when I change border width from 1px to 0px. That changes the layout of divs. The divs should be stacked step by step in the influence of margin, but when I set the border width as 0px, the top margin becomes 0px.
This is my code.
div {
height: 300px;
width: 50%;
margin: 10px;
border: 1px solid red;
}
.red {
background-color: #ffcccc;
}
.green {
background-color: #ccffcc;
}
.blue {
background-color: #ccccff;
}
.purple {
background-color: #cccccc
}
<div class="red">
<div class="green">
<div class="blue">
<div class="purple"></div>
</div>
</div>
</div>