JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="item item1"></div>
<div class="item item2"></div>
<div class="item item3"></div>
<div class="item item4"></div>
<div class="item item5"></div>
<div class="item item6"></div>
</div>
CSS
body {
background: rgba(0, 0, 0, .02)
}
.container {
display: flex;
flex-flow: column wrap;
align-content: space-between;
height: 580px;
}
.item {
width: 32%;
margin-bottom: 2%; /* (100-32*3)/2 */
background: #fff;
border-radius: 10px;
box-shadow: 0px 1px rgba(0, 0, 0, .1), 1px 0px rgba(0, 0, 0, .1)
}
/* Re-order items into rows */
.item:nth-child(3n+1) { order: 1; }
.item:nth-child(3n+2) { order: 2; }
.item:nth-child(3n) { order: 3; }
/* Force new columns */
.container::before,
.container::after {
content: "";
flex-basis: 100%;
width: 0;
order: 2;
}
.item1 {
height: 150px;
}
.item2 {
height: 200px;
}
.item3 {
height: 100px;
}
.item4 {
height: 180px;
}
.item5 {
height: 120px;
}
.item6 {
height: 170px;
}