I have a container with fixed width and height where I want to display an image and some text. My goal is to have the text appear first, followed by the image filling up the remaining space in the container. Check out the image below for reference:
Although it seems like this approach should work, the image doesn't respect the height of the row it's placed in:
.container {
width: 500px;
height: 300px;
background-color: green;
display: grid;
grid-template-rows: 1fr auto;
gap: 40px;
}
img {
object-fit: contain;
width: 100%;
background-color: red;
}
span {
background-color: blue;
}
<a href='somelink' class="container">
<img src="https://cdn.pixabay.com/photo/2017/02/07/16/47/kingfisher-2046453_960_720.jpg" alt="">
<span>Test</span>
</a>