I have a CSS grid with two columns.
I may or may not render content inside the first column. In other words, the column div will always be present, it's just that sometimes it might not have content therein.
When there is no content in the first column I don't want that column to take up space, and when there is content I want it to have a max width of 100px
.
Is it possible to do this via the CSS Grid definition alone?
#container {
display: grid;
grid-template-columns: minmax(auto, 100px) auto;
grid-gap: 5px;
height: 200px;
width: 100%;
background-color: #8cffa0;
padding: 10px;
}
#container > div {
background-color: #c0c0c0;
}
<div id="container">
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
<div>
Placeat, rerum illo eligendi, hic eum magnam quo architecto necessitatibus sunt sequi repellendus suscipit fuga tenetur atque corrupti modi saepe! Iusto, provident.
</div>
</div>