This is a problem I never understood. Lets say I have a container and one or several divs in the container. When the last item has a margin-bottom it does not increase the size of the container, if the container does not have a padding-bottom or border.
The example shows some workaround but I have no idea why the browser or spec behaves like that.
.item {
height: 20px;
background: red;
margin-bottom: 10px;
}
.container {
padding: 10px;
padding-bottom: 0;
background: blue;
margin-bottom: 20px;
}
.container2 {
padding: 10px;
padding-bottom: 0.1px;
background: green;
margin-bottom: 20px;
}
.container3 {
padding: 9px;
padding-bottom: 0;
border: 1px solid green;
background: green;
margin-bottom: 20px;
}
<div class="container">
<div class="item">
</div>
<div class="item">
</div>
<div class="item">
</div>
</div>
<div class="container2">
<div class="item">
</div>
<div class="item">
</div>
<div class="item">
</div>
</div>
<div class="container3">
<div class="item">
</div>
<div class="item">
</div>
<div class="item">
</div>
</div>