I have a container with a title and an image. I want the image to take the remaining space in the container so im using flex-grow. The container takes the remaining space but when I add the image, they image extends over the container.
Setting opacity of innerWrapper to 50% to see how the image extends past the container.
#container {
width: 500px;
height: 200px;
background-color: black;
display: flex;
flex-direction: column;
}
#title {
color: white;
font-weight: bold;
background-color: gray;
font-size: 28px;
}
#imageWrapper {
background-color: red;
width: 100%;
flex: 1;
opacity: 50%;
}
#image {
object-fit: cover;
width: 100%;
height: 100%;
}
<div id="container">
<div id="title">Title</div>
<div id="imageWrapper">
<img id="image" src="https://estnn.com/wp-content/uploads/2020/08/FNC-header-800x450.png">
</div>
</div>