JSFiddle - React, Tailwind, and code Playground
HTML
<section id="home">
<div class="container">
Test
</div>
</section>
CSS
#home {
background-image: url('https://dl.dropboxusercontent.com/u/62537/jsfiddleBG/background02.jpg');
background-size: 100% 100% !important;
background-repeat: no-repeat;
background-position: center;
}
.container {
width: 400px;
height: 500px;
display: block;
background: red;
margin: 0 auto;
}
JavaScript
$(document).ready(function() {
var $w = $(window),
$h = $('#home'),
aspectRatio = 1920 / 1280;
function resizeBg() {
$h.width($w.width());
if( ( $h.width()/aspectRatio ) <= $("> .container", $h).height() ) {
$h.width( $(" > .container", $h).height()*aspectRatio );
}
$h.height( $h.width()/aspectRatio);
}
$w.resize(resizeBg);
$w.onload=resizeBg();
});