<div class="container">
<p>Change the value of the <code>object-fit</code> property to see the image content change accordingly.</p>
<p>
This is the original image:
</p>
<img src="http://tympanus.net/codrops-playground/assets/images/cssref/properties/object-fit/duck.jpg" alt="">
<p>This is the image after being sized using <code>object-fit</code>:</p>
<img class="fit" src="http://tympanus.net/codrops-playground/assets/images/cssref/properties/object-fit/duck.jpg" alt="">
</div>
body {
color: #555;
font-size: 1.1em;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.container {
margin: 40px auto;
max-width: 700px;
}
img {
max-width: 100%;
}
img.fit {
border: 5px solid maroon;
width: 10em;
height: 10em;
-o-object-fit: contain;
object-fit: contain;
}