I want to break a flexbox column container after every 4th element. For that I defined a max-height, since I know the height of every element.
.subnav {
position: absolute;
top: 5px;
left: 20px;
}
ul {
display: flex;
flex-flow: column wrap;
list-style: none;
max-height: 80px;
background-color: grey;
padding: 0px;
}
li {
box-shadow: inset 0 0 1px #000;
text-align: center;
width: 200px;
}
li:nth-child(4n) {
flex-basis: 100%;
}
<div class="subnav">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
</div>
The flex container renders its child elements correctly, but the actual size of the container (grey area) is smaller. Why is this the case and how can I fix it?