I have a parent with flexbox
and an image in that element with max-height
and max-width
. This displays fine in Chrome (ofc), but on Firefox the image is displayed with height:100%
and width:100%
while in IE it's displayed with width
way over 100%
.
I've created an example on codepen.
HTML:
<div id='flex'>
<img src='https://www.google.se/images/srpr/logo11w.png' />
</div>
CSS:
#flex {
align-items: center;
-webkit-align-items: center;
-ms-flex-align: center;
display:block;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width:200px;
height:200px;
}
img {
max-height: 100%;
max-width:100%;
}
How do I display the image with max-height
and max-width
"normally" (display:block;
on #flex
)? I need display:flex
so I can display the image in the center (vertically). If you change display
to block
on codepen you'll see how the image should look like.
How it looks like in Chrome (correct):
How it looks like in Firefox:
How it looks like in IE11: