The problem is that both the image and its containing block have
max-height: 100%;
max :
.flex-item {
width: 100%;
height: 100%;
}
html,
body {
height: 100%;
margin: 0;
}
.flex-container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: green;
}
.flex-item {
width: 100%;
height: 100%;
}
img {
max-width: 100%;
max-height: 100%;
}
<div class="flex-container">
<div class="flex-item">
<img src="http://i.stack.imgur.com/mrEyQ.jpg">
</div>
</div>
Hide result, .flex-item .flex-container, .flex-item.
, (, , flexbox).
html,
body {
height: 100%;
margin: 0;
}
.flex-container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background: green;
}
.flex-item {
width: 100%;
height: 100%;
text-align: center;
}
.flex-item:after {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
img {
max-width: 100%;
max-height: 100%;
vertical-align: middle;
}
<div class="flex-container">
<div class="flex-item">
<img src="http://i.stack.imgur.com/mrEyQ.jpg">
</div>
</div>
Hide result