I have been working with Grid for a while now and there is one thing I still can't quite figure out. When working with a two column layout, There are times when the content of one column forces the other column's content to have big gap beneath it because the first columns content is longer. Is there is a way to make each grid cell shrink vertically to fit the content of that cell? See the attached snippet for an example.
.parent {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-column-gap: 30px;
grid-row-gap: 30px;
max-width: 300px;
}
.child {
border: 1px solid #000;
}
<div class="parent">
<div class="child">
Content Content Content
</div>
<div class="child">
Content Content Content Content Content Content Content
</div>
<div class="child" id="child2">
Content Content Content
</div>
<div class="child">
Content Content Content
</div>
</div>
In this snippet, you will see the content of the top left grid area has a large gap beneath due to the top right's content. Is there a way to make it shrink to remove the gap? I'm not entirely sure this is possible with grid alone though.