JSFiddle - React, Tailwind, and code Playground
by KURO KUMO
HTML
<header>HEADER</header>
<div class="slide-wrapper" style="background: url('-- image for devices since video should be display: none !important; --') white no-repeat center center; background-size: cover;">
<div class="full-video-wrapper">
<video id="full-video" muted preload autoplay loop>
<source src="http://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
<!-- fallback image -->
<img src="--- jpg/png here ---" class="video-player--fallback-image" />
</video>
</div>
</div>
<main>MAIN CONTENT</main>
<footer>
<section class="footer-up">LINKS</section>
<section class="footer-down">COPYRIGHT</section>
</footer>
CSS
html,
body {
text-align:center;
margin: 0;
padding: 0;
min-height: 100%;
height: 100%;
width: 100%
}
header{
width:100%;
height:80px;
background:#fff;
line-height:80px
}
.slide-wrapper {
display: block;
width: 100%;
height: 400px;
margin: 0;
padding: 0;
}
.full-video-wrapper {
background: white;
position: absolute;
top: 80px;
right: 0;
bottom: 0;
left: 0;
min-width: 100%;
min-height: 400px;
width: auto;
height: 400px;
z-index: 1;
overflow: hidden;
}
#full-video {
display: block;
position: absolute;
min-height: 100%;
min-width: 100%;
width: auto;
height: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
main{
background:#eee;
height:400px;
line-height:400px
}
.footer-down{
height:120px;
line-height:120px;
background:white;
}
.footer-up{
background:#333;
line-height:300px;
height:300px;
color:white;
}
JavaScript
var $win = $(window),
$video = $('#full-video'),
$videoWrapper = $video.parent();
function scaleVideo() {
var isWider = ($video.width() > $videoWrapper.width()) ? true : false,
isTaller = ($video.height() > $win.height()) ? true : false,
widthDifference = $video.width() - $videoWrapper.width(),
heightDifference = $video.height() - $videoWrapper.height();
(isWider) ? $video.css('left', -parseInt(widthDifference / 2)): $video.css('left', '0');
(isTaller) ? $video.css('top', -parseInt(heightDifference / 2)): $video.css('top', '0');
}
scaleVideo();
$win.resize(function() {
scaleVideo();
});