See:
http://www.championfreight.co.nz
See:
http://www.championfreight.co.nz/freight
See:
http://www.championfreight.co.nz/resources
Html (inside html element):
<video id="bgvid" autoplay loop muted preload poster="http://www.championfreight.co.nz/uploads/ship_01_2000.jpg">
<source src="video/container_ship_01.webm" type="video/webm" />
<source src="video/container_ship_01.mp4" type='video/mp4' />
</video>
Note: Make sure you set the html element to z-index -200, so it sits nicely at the back.
CSS:
#bgvid {
position:absolute;
bottom: 0%;
left: 50%;
min-width: 100%;
min-height: 100vh;
width: auto;
height: auto;
-ms-transform: translate(-50%, 0%);
-moz-transform: translate(-50%, 0%);
-webkit-transform: translate(-50%, 0%);
-o-transform: translate(-50%, 0%);
transform: translate(-50%, 0%);
}
@media screen and (max-width: 93.75em) {
/* Rules when screen resolution is less than 1500px */
#bgvid {
position:absolute;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
-ms-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%,-50%);
}
}
A couple of more tips:
1. This code is based on hosting your own video. There can be SEO benefits doing this, especially if the file is nice and compressed (I like to keep it under 6,500 KB). For this reason, my background videos usually loop under 20 seconds, otherwise they can be too big.
2. I use Handbrake (free software) to condense my video files while retaining image quality. Search the web to download and view tutorials.
3. I usually don't have my videos playing for mobile devices.
Hope this helps.