Skip to content

Instantly share code, notes, and snippets.

@denisnazarov
Created December 24, 2013 21:24
Show Gist options
  • Save denisnazarov/8117906 to your computer and use it in GitHub Desktop.
Save denisnazarov/8117906 to your computer and use it in GitHub Desktop.
Full screen (background) video with just CSS: http://jsbin.com/EzakOYIb/1
.full-screen-video-container{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
overflow: hidden;
}
.full-screen-video-container video{
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
min-width: 100%;
min-height: 100%;
}
<div class="full-screen-video-container">
<video autoplay="autoplay" loop poster="http://media.w3.org/2010/05/bunny/poster.png">
<source id="mp4" src="http://media.w3.org/2010/05/bunny/movie.mp4" type="video/mp4">
<source id="ogv" src="http://media.w3.org/2010/05/bunny/movie.ogv" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment