html - Responsive HTML5 Video -
i trying make video fill entire window width , height. video should resize, if window resized. therefore might have change aspect ratio. got scrolling bars on right, should removed somehow.
this code far:
html:
<html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <video autoplay loop id="bgvid"> <source src="myvideo.mp4" type="video/mp4"> </video> </body> </html>
css
video#bgvid { position: absolute; top: 50%; left: 50%; min-width: 100%; min-height: 100%; transform: translate(-50%, -50%); z-index: -100; -webkit-transform: translatex(-50%) translatey(-50%); transform: translatex(-50%) translatey(-50%); }
jsfiddle : http://jsfiddle.net/6u1krl0l/
to fill complete window should ensure video have same aspect ratio window, tricky.
i think best option ensure fill width or height , fill background black color.
try following: html
<div id="wrapper"> <video autoplay loop id="bgvid"> <source src="myvideo.mp4" type="video/mp4" /> </video> </div>
css
#wrapper { position: absolute; top:0; left:0; right:0; bottom:0; background-color: black; } video#bgvid { width: 100%; position: relative; top: 50%; transform: translatey(-50%); }
Comments
Post a Comment