I currently have a container with items having varying heights. I'm displaying them in columns of 5 and 3 items max per line. I tried the following implementation but there are huge gaps in the row that I can't seem to remove. How would I fix this?
body {
background-color: #1E1E1E;
display: flex;
justify-content: center;
}
.masonry {
width: 1200px;
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: repeat(3, auto);
grid-row-gap: 10px;
}
.cell {
background-color: #fff;
width: 240px;
margin: 10px;
}
<div class="masonry">
<div style="height: 180px" class="cell"></div>
<div style="height: 240px" class="cell"></div>
<div style="height: 520px" class="cell"></div>
<div style="height: 120px" class="cell"></div>
<div style="height: 240px" class="cell"></div>
<div style="height: 332px" class="cell"></div>
<div style="height: 143px" class="cell"></div>
<div style="height: 306px" class="cell"></div>
<div style="height: 514px" class="cell"></div>
<div style="height: 232px" class="cell"></div>
<div style="height: 361px" class="cell"></div>
<div style="height: 234px" class="cell"></div>
<div style="height: 318px" class="cell"></div>
</div>