I have a grid of images which are to display in a single row. The grid's height is not to exceed the height of the browser. Each image can my any height and any width.
The image must be vertically and horizontally centered in its container. If the image's height or width is bigger than its container, then the image should not overflow its bounds.
Is this possible?
There are many posts out there asking similar questions.
Constrain img to div and maintain aspect ratio?
CSS: How can I set image size relative to parent height?
And so on. However none that I see are using flexbox.
<div class='grid-container'>
<div class='grid'>
<div class='col'>
<div class='img-container'>
<img src='http://via.placeholder.com/300x150'/>
</div>
</div>
<div class='col'>
<div class='img-container'>
<img src='http://via.placeholder.com/200x400'/>
</div>
</div>
</div>
</div>
https://codepen.io/stljeff1/pen/MEWoPN
Here is a codepen showing what I'm trying to do
Why does img {max-height: 100%; }
not do anything but img { height: 150px; }
constrains the image?
**********Edit**************** as pointed out in comments below, I could use object-fit. The example cited Works in IE Edge, not IE 11.