JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<iframe src="https://player.vimeo.com/video/135335257?autoplay=false" width="640" height="360" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
</div>
CSS
body, html {height:100%; margin:0;}
.container {
position: absolute;
top: 0;
overflow: hidden;
}
JavaScript
var min_w = 300; // minimum video width allowed
var vid_w_orig; // original video dimensions
var vid_h_orig;
jQuery(function() { // runs after DOM has loaded
vid_w_orig = parseInt(jQuery('iframe').attr('width'));
vid_h_orig = parseInt(jQuery('iframe').attr('height'));
jQuery(window).resize(function () { resizeToCover(); });
jQuery(window).trigger('resize');
});
function resizeToCover() {
// set the video viewport to the window size
jQuery('.container').width(jQuery(window).width());
jQuery('.container').height(jQuery(window).height());
// use largest scale factor of horizontal/vertical
var scale_h = jQuery(window).width() / vid_w_orig;
var scale_v = jQuery(window).height() / vid_h_orig;
var scale = scale_h > scale_v ? scale_h : scale_v;
// don't allow scaled width < minimum video width
if (scale * vid_w_orig < min_w) {scale = min_w / vid_w_orig;};
// now scale the video
jQuery('iframe').width(scale * vid_w_orig);
jQuery('iframe').height(scale * vid_h_orig);
// and center it by scrolling the video viewport
jQuery('.container').scrollLeft((jQuery('iframe').width() - jQuery(window).width()) / 2);
jQuery('.container').scrollTop((jQuery('iframe').height() - jQuery(window).height()) / 2);
};