I'm creating a list of items, and I found something weird:
In a list of items, where each item has a margin bottom, the margin-bottom of the last item overflows the parent element except if the parent element has a border.
.Item {
display: inline-block;
}
.Parent1 {
border: 1px solid black;
}
.Parent2 {
outline: 1px solid black;
}
.Child {
height: 15px;
width: 30px;
margin-bottom: 15px;
border: 1px dashed black;
}
<div class="Item">
<h2>With border</h2>
<div class="Parent1">
<div class="Child">a</div>
<div class="Child">b</div>
<div class="Child">c</div>
</div>
</div>
<div class="Item">
<h2>With outline</h2>
<div class="Parent2">
<div class="Child">a</div>
<div class="Child">b</div>
<div class="Child">c</div>
</div>
</div>
I can't figure out the reason of this behaviour. I can fix it with overflow: auto
, but I'm looking for a proper explanation of this issue.