JSFiddle - React, Tailwind, and code Playground
by Ben Philipp
HTML
<div class="container">
<div class="box">
<img src="http://placehold.it/300"/>
</div>
</div>
CSS
body, html {
height: 100%;
margin: 0;
padding: 0;
overflow:hidden;
position:relative;
}
.container {
width: 100%;
max-width: 100%;
height: 100%;
max-height: 100%;
}
.box {
background: yellow;
width: 100%;
padding: 0 5%;
box-sizing:border-box;
max-width: 100%;
height: 100%;
max-height:100%;
position:relative;
}
.box img {
height: auto;
height:100%;
max-height: 100%;
// min-height: 100%;
width: auto;
max-width: 100%;
margin: auto;
position:absolute;
top:0%;
bottom:0%;
left:0%;
right:0%;
display:block;
object-fit: contain;
}