Can someone please explain for me why the ".child" elements exceed their parent but no overflow-y scroll bar appears? Have a look at the Pen. The container on the left shows the parent with 3 child items. The container on the right shows the parent with 6 items which exceed the parent.
The goal is to have all ".child" items pushed to the bottom of their ".parent" container and if i add more it will expand from the bottom to top until it reaches the limit of the parent, at which point the scroll bar appears. This would be similar behavior to a chatbox messenger window.
.outside {
height: 200px;
width: 200px;
border: 4px solid green;
overflow-y: auto;
}
.parent {
height: 100%;
width: 200px;
display: flex;
flex-direction: column;
justify-content: flex-end;
overflow-y: auto;
}
.child {
height: 40px;
width: 100%;
background: #f00;
flex: 0 0 auto;
}
.child:nth-child(odd) {
background: red;
}
.child:nth-child(even) {
background: blue;
}
<div class="outside" style="float:left; margin-right:10px">
<div class="parent">
<div class="child">
Align to the bottom 1
</div>
<div class="child">
Align to the bottom 2
</div>
<div class="child">
Align to the bottom 3
</div>
</div>
</div>
<div class="outside">
<div class="parent">
<div class="child">
Align to the bottom 1
</div>
<div class="child">
Align to the bottom 2
</div>
<div class="child">
Align to the bottom 3
</div>
<div class="child">
Align to the bottom 4
</div>
<div class="child">
Align to the bottom 5
</div>
<div class="child">
Align to the bottom 6
</div>
</div>
</div>