I have come across a case where I need a child's margin to expand a parent container. I found that the space outside of the parent is allocated, but the parent itself is not expanded. I then found that by adding overflow: hidden to the parent I could fix this issue.
Can anyone shed any light on why this is the case?
I have found that adding any padding or border value to the parent also fixes this.
section {
background: black;
//overflow: hidden; /* toggle this */
//padding: 1px; /* or toggle this */
//border: solid 1px green; /* or toggle this */
}
div {
margin: 10px;
background: red;
}
<section>
<div>
SOME CONTENT
</div>
</section>