I'm currently utilizing CSS grid to construct a basic 3 column layout. Here's a snippet of my code...
.container {
display:grid;
grid-template-columns:1fr 1fr 1fr;
}
.col1 {
background:red;
text-align:center;
}
.col2 {
background:yellow;
text-align:center;
}
.col3 {
text-align:center;
background:green;
}
<div class="container">
<div class="col1">
Column 1
</div>
<div class="col2">
<img src="https://via.placeholder.com/150">
</div>
<div class="col3">
Column 3
</div>
</div>
I am attempting to modify the setup so that the middle div is only as wide as the image it contains, while col1
and col2
expand to fill up the remaining space.
Is there someone who can provide me with a sample example?