JSFiddle - React, Tailwind, and code Playground
by Trisox
HTML
<div id="page">
Your page contents here..
</div>
<div id="background-container">
<img src="http://img.dailymail.co.uk/i/pix/2007/07_03/nasaR3107_1000x1000.jpg" />
</div>
CSS
html,body{padding:0;margin:0;width:100%;height:100%;}
#background-container{
position:absolute;
z-index:1;
top:0;
left:0;
width:100%;
height:100%;
overflow:hidden;
}
#page{
position:relative;
z-index:5;
background-color:white;
opacity:0.8;
width:400px;
height:300px;
}
JavaScript
$(function(){
var stretcher = $('#background-container > img'),
element = stretcher[0],
currentSize = { width: 0, height: 0 },
$document = $(document);
$(window).resize(function () {
var w = $document.width();
var h = $document.height();
if (currentSize.width != w || currentSize.height != h) {
stretcher.width(w).height('auto');
if (h > element.height) {
stretcher.width('auto').height(h);
}
currentSize.width = w;
currentSize.height = element.width;
}
})
$(window).load(function () {
$(this).trigger('resize');
});
});