Let's consider some container with display: flex
. There are some elements in it.
All elements have the same height because default value of align-items
is stretch
.
One of these elements is an image.
Is it possible to preserve aspect ratio of this image?
So I have this:
.container {
display: flex;
}
.description {
height: 200px;
background: yellow;
}
<div class="container">
<img class="image" src="http://placehold.it/200x100" />
<div class="description">
Some text of 200px height
</div>
</div>
And I want to achieve the following result without specifying the height of the container
.container {
display: flex;
height: 200px;
}
.image {
height: 100%;
}
.description {
height: 200px;
background: yellow;
}
<div class="container">
<img class="image" src="http://placehold.it/200x100"/>
<div class="description">
Some text of 200px height
</div>
</div>