I have a problem with image in a flex container. I want it to keep ratio when the container/window height is decreased/resized down.
html,
body {
height: 100%;
}
.wrapper {
display: flex;
width: 100%;
height: 60%;
border: 1px solid red;
}
.image-container {
display: flex;
align-items: center;
max-width: 30%;
height: 100%;
background: green;
}
img {
max-width: 100%;
max-height: 100%;
}
.content {
display: flex;
justify-content: center;
align-items: center;
flex: 1;
width: 100%;
height: 100%;
background: yellow;
}
<div class="wrapper">
<div class="image-container">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Clouds_over_the_Atlantic_Ocean.jpg/1200px-Clouds_over_the_Atlantic_Ocean.jpg" alt="">
</div>
<div class="content">
<span>Some content</span>
</div>
</div>
When you try to do it you can see that only image's height changes but width stays the same and the image is kind of stretched.
When I delete 'display: flex' from the image container, an image resizes well. I made it flex because i wanted it to be centered.
Is there a way to keep the ratio and fluidly resize image and the rest of containers?