I have a div that has flex-wrap, so the number of columns is decided on the fly. I then want to have this in a container, which has some padding and a different background color. I assume this is possible, but can't get it to work...
.container {
background-color: blue;
display: inline-block;
padding: 5px;
}
.columns {
height: 100px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
background-color: green;
}
<div class="container">
<div class="columns">
<span>One</span>
<span>Two</span>
<span>Three</span>
<span>Four</span>
<span>Five</span>
<span>Six</span>
<span>Seven</span>
</div>
</div>
https://codepen.io/Mersaul4/pen/dygKJyw
The parent should not take the whole page, that's why I am not using display: block
.