JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div class="wrapper">
<div class="header">
<nav> <a href="http://braaasil.com/mysite/indexVideo.html">Video</a> <a href="cnn.com/">Blog</a> <a href="/js/">Glob</a> <a href="/jquery/">Lgob</a>
<a href="/jquery/">Contact</a>
</nav>
</div>
<div class="out-video">
<div id="video-viewport">
<video autoPlay controls preload width="640" height="360">
<source src="http://www.html5rocks.com/en/tutorials/video/basics/devstories.mp4" type="video/mp4" />
<source src="http://www.html5rocks.com/en/tutorials/video/basics/devstories.webm" type="video/webm" />
</video>
</div>
<div class="main_text"></div>
</div>
</div>
CSS
@charset"utf-8";
* {
margin: 0;
padding: 0;
}
/* CSS Document */
html, body {
width:100%;
height:100%
}
.wrapper {
width:100%;
height:100%;
}
.out {
position:relative;
background-image: url(../images/melissa.JPG);
background-repeat: no-repeat;
background-size: 100% 100%;
height:100%;
width:100%;
color:red;
}
.out-video {
position: relative;
min-width:100% !important;
height:82% !important;
z-index: -1;
margin:0;
padding:0;
overflow: hidden;
}
.header {
height:15%;
position:relative;
background-color:black;
border-bottom:solid;
border-bottom-width:10px;
border-bottom-color:#777
}
button {
position: relative;
left:75%;
top:15%;
}
nav {
position:absolute;
bottom:0;
left:15%
}
nav a {
font-variant:small-caps;
font-size:24px;
font-weight:bold;
padding:10px;
text-decoration:none;
color:white;
position:relative;
}
.main_text {
color: white;
font-size:76px;
font-variant:small-caps;
position:absolute;
right:15%;
top:30%;
}
video#bgvid {
position: relative;
z-index: 0;
background: url(mel.jpg) no-repeat;
background-size: 100% 100%;
top: 0px;
left: 50%;
margin-left: -50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
}
#video-viewport {
position: absolute;
top: 0;
overflow: hidden;
z-index: -1; /* for accessing the video by click */
}
#debug {
position: absolute;
top 0;
z-index: 100;
color: #fff;
font-size: 12pt;
}
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('video').attr('width'));
vid_h_orig = parseInt(jQuery('video').attr('height'));
$('#debug').append("<p>DOM loaded</p>");
jQuery(window).resize(function () { resizeToCover(); });
jQuery(window).trigger('resize');
});
function resizeToCover() {
// set the video viewport to the window size
jQuery('#video-viewport').width(jQuery(window).width());
jQuery('#video-viewport').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('video').width(scale * vid_w_orig);
jQuery('video').height(scale * vid_h_orig);
// and center it by scrolling the video viewport
jQuery('#video-viewport').scrollLeft((jQuery('video').width() - jQuery(window).width()) / 2);
jQuery('#video-viewport').scrollTop((jQuery('video').height() - jQuery(window).height()) / 2);
};