"Fullscreen Background Video"
Bootstrap 3.0.0 Snippet by ALIMUL AL RAZY

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div id="video-container">
<video preload="auto" autoplay loop muted width="1440" height="810">
<source src="http://www.xtianmiller.com/dist/videos/winter_creek.mp4" type="video/mp4">
<source src="http://www.xtianmiller.com/dist/videos/winter_creek.webm" type="video/webm">
</video>
</div>
<div class="overlay">
<div class="overlay__inner">
<h2>Fullscreen HTML5 Background Video</h2>
<p>
Utilizes Javascript to create cover effect and updates on resize. Modernizr determines an image fallback for touch devices.
</p>
<a href="http://xtianmiller.com/notes/fullscreen-html5-background-video/" class="btn" target="_blank">
<span class="row1">Read Article</span>
<span class="row2">Read Article</span>
</a>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
html, body {
overflow-x: hidden;
width: 100%;
min-height: 100%;
}
body {
background: #1d1f20;
color: #aaa;
font-size: 18px;
line-height: 1.4;
font-family: 'Inconsolata', sans-serif;
}
* {
box-sizing: border-box;
}
#video-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
z-index: 10;
overflow: hidden;
}
.touch #video-container {
background: url(http://xtianmiller.com/dist/videos/winter_creek.jpg) no-repeat center;
background-size: cover;
}
video {
width: 100%;
height: 100%;
}
.touch video {
display: none;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
function debounce(func, wait, immediate) {
// Debounce
// http://davidwalsh.name/javascript-debounce-function
var timeout;
return function() {
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
func.apply(context, args);
}
};
}
var htmlTag = document.getElementsByTagName('html')[0];
var videoContainer = document.querySelector('#video-container');
var videoElem = document.querySelector('#video-container video');
var minW = 320; // Minimum video width allowed
var vidWOrig; // Original video dimensions
var vidHOrig;
vidWOrig = videoElem.getAttribute('width');
vidHOrig = videoElem.getAttribute('height');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: