I have a flexbox container and two flex box items: item-img
and item-content
. item-img
have an image in it. I want item-img
have height equal the height of item-content
and the image will cover all space of it.
It means the item-img
's height is set based on the item-content
's height. The item-content
's height is not fixed and may much bigger or much smaller than the height of the image.
Any help would be appreciated. Thanks so much.
.flex-container {
display: flex;
width: 500px;
border: solid 1px #123;
}
.flex-item {
max-width: 50%;
overflow: hidden;
flex-basis: 50%;
}
.item-img {
display: flex;
}
img {
object-fit: cover;
}
<div class="flex-container">
<div class="flex-item item-img">
<img src="http://via.placeholder.com/350x350">
</div>
<div class="flex-item item-content">
<p>This is conent with text</p>
<p>more text</p>
<p>more text</p>
<p>more text</p>
<p>more text</p>
<p>more text</p>
</div>
</div>