Let's have a simple demo showing inline-flex
functionality: https://jsfiddle.net/p3mztw4e/
div.c1 {
background: #ddd;
display: inline-flex;
flex-wrap: wrap;
margin: 0 auto;
}
div.c3 {
border-color: #0f0;
border-style: solid;
border-width: 3px;
margin: 5px;
vertical-align: top;
}
<center>
<div class="c1">
<div class="c3">
111111111111111111<br>abc
</div>
<div class="c3">
22222222222222222
</div>
</div>
<br><br>
<div class="c1">
<div class="c3">
111111111111111111<br>abc
</div>
<div class="c3">
22222222222222222
</div>
<div class="c3">
3333333333333333
</div>
<div class="c3">
444444444444444
</div>
<div class="c3">
55555555555555
</div>
<div class="c3">
6666666666666
</div>
<div class="c3">
777777777777<br>def
</div>
<div class="c3">
88888888888888888
</div>
<div class="c3">
9999999999999
</div>
</div>
</center>
The result looks like this:
While the single-row inline-flex
div
works fine and it is centered as expected, the multi-row inline-flex
div
is not centered.
Why?
Please note that the number of "columns" is not fixed. Window resizing should change its number to fit as many as possible.
How can we center the entire content with multiple rows?