JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="inner">
<div class="box">
<img src="https://en.gravatar.com/userimage/22632911/5cc74047e143f8c15493eff910fc3a51.jpeg"/>
</div>
</div>
</div>
CSS
body {
background-color: black;
}
.inner {
background-color: white;
width: 800px;
height: 600px;
-webkit-transform-origin: 0 0;
}
.box {
overflow: hidden;
-webkit-border-radius: 10px;
width: 80px;
height: 80px;
margin: 10px;
}
JavaScript
(function ($) {
var $inner = $('.inner');
var $window = $(window);
var iWidth = parseInt($inner.css('width'));
var iHeight = parseInt($inner.css('height'));
var iRatio = iWidth / iHeight;
function adjustScale() {
var vWidth = $window.width();
var vHeight = $window.height();
if (vWidth / vHeight > iRatio) {
width = vHeight * iRatio;
} else {
width = vWidth;
}
var scale = width / iWidth;
$inner[0].style.WebkitTransform = 'scale(' + scale + ')';
}
adjustScale();
$window.resize(adjustScale);
})(jQuery);