Maybe I'm wrong, but I don't think that you can achieve this with flex
. You can try with float: left;
on children but you still end up with that space below the content in some places.
You can look up for the Masonry layout solution in JS.
Or you can use column-count: 3;
it will remove those white spaces, but it will work like this:
A D G
B E H
C F J
(from the top to the bottom like in a newspaper)
I've added those two rules in the ul to block the division of those blocks between columns.
display: inline-block;
width: 100%;
.wrapper {
column-count: 3;
}
.wrapper ul {
display: inline-block;
width: 100%;
list-style: none;
padding: 0;
margin: 0 0 1em;
}
<div class="wrapper">
<ul>
<li>List 1 - child</li>
<li>List 1 - child</li>
<li>List 1 - child</li>
<li>List 1 - child</li>
<li>List 1 - child</li>
<li>List 1 - child</li>
</ul>
<ul>
<li>List 2 - child</li>
<li>List 2 - child</li>
<li>List 2 - child</li>
</ul>
<ul>
<li>List 3 - child</li>
<li>List 3 - child</li>
<li>List 3 - child</li>
<li>List 3 - child</li>
<li>List 3 - child</li>
</ul>
<ul>
<li>List 4 - child</li>
<li>List 4 - child</li>
<li>List 4 - child</li>
<li>List 4 - child</li>
<li>List 4 - child</li>
</ul>
<ul>
<li>List 5 - child</li>
<li>List 5 - child</li>
<li>List 5 - child</li>
</ul>
<ul>
<li>List 6 - child</li>
<li>List 6 - child</li>
</ul>
<ul>
<li>List 7 - child</li>
<li>List 7 - child</li>
<li>List 7 - child</li>
<li>List 7 - child</li>
<li>List 7 - child</li>
</ul>
<ul>
<li>List 8 - child</li>
<li>List 8 - child</li>
<li>List 8 - child</li>
<li>List 8 - child</li>
</ul>
<ul>
<li>List 9 - child</li>
<li>List 9 - child</li>
<li>List 9 - child</li>
<li>List 9 - child</li>
<li>List 9 - child</li>
<li>List 9 - child</li>
<li>List 9 - child</li>
<li>List 9 - child</li>
</ul>
<ul>
<li>List 10 - child</li>
<li>List 10 - child</li>
</ul>
</div>