I am using flexbox to create a nice grid of tiles that automatically wraps when the tiles don't fit on one row.
I use justify-content: space-between
so that the tiles stick to the left and right sides of the parent container, and any remaining space is only distributed "in the middle" but not to the left and right.
Any other justify
option also puts space to the left and right of the outer two flex items.
The problem is that when a row doesn't have the same number of tiles as the previous row, I'd like the last row's tiles to align to the left. Can this be done using only flex properties?
Current outcome:
▀ ▀ ▀
▀ ▀
Desired outcome:
▀ ▀ ▀
▀ ▀
HTML
<div class="browser">
<div @click='projectClicked' class="case">
<h3>Project</h3>
</div>
<div @click='projectClicked' class="case">
<h3>Project</h3>
</div>
<div @click='projectClicked' class="case">
<h3>Project</h3>
</div>
<div @click='projectClicked' class="case">
<h3>Project</h3>
</div>
<div @click='projectClicked' class="case">
<h3>Project</h3>
</div>
</div>
CSS
.browser {
width: 700px;
display:flex;
justify-content: space-between;
padding-bottom:100px;
flex-wrap:wrap;
border:1px solid red;
}
.case {
flex: 0 0 200px;
background-color:#ccc;
height:100px;
border:1px solid blue;
margin-bottom:10px;
}