I have a flexbox that can contain an arbitrary number of items and I've set it to be a specific size.
When I have a bunch of items in there the items get squeezed together vertically which is the behavior I want, but if there's only a few they space out to evenly fill the vertical space. How can I make it so that they always squeeze together?
.container {
height: 300px;
width: 500px;
display: flex;
flex-direction: row;
border: solid;
flex-wrap: wrap;
overflow-y: auto;
}
.flex-1 {
height: 100px;
width: 100px;
background-color: blue;
border: solid;
}
<p>The blue boxes should be flush against each other vertically</p>
<div class="container">
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
</div>
<br>
<p>When there's a whole bunch it works correctly</p>
<div class="container">
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
<div class="flex-1"></div>
</div>