I have a flex container with two elements: an image and a small piece of descriptive text. I want the image to be responsive but not grow beyond a certain height, which is causing a gap when the screen width expands beyond the max height of the image.
Is there a way to make the container item adapt to the image's size so there are no gaps, or to align the image to the left or right side of the screen? I've tried using self-align, but it doesn't seem to be working. I'm looking for a solution to this issue.
.container {
background-color: #FFEEDD;
display: flex;
flex-direction: row-reverse;
}
.container>.image {
flex-grow: 1;
}
.image img {
display: block;
max-width: 100%;
max-height: 300px;
}
.container>.text {
flex-grow: 2;
}
<div class="container">
<div class="image">
<img src="https://www.placecage.com/c/1500/2000">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloribus aliquid eius.
</div>
</div>