Has anyone figured out how to make an HTML5 video in an absolutely positioned <video>
element resize to fit the window width and height without ever getting cropped? Many solutions I've come across rely on using the <iframe>
tag, which is not an option for me, or only adjust based on width (something I can already do).
Essentially, I want the video to be as large as possible while also ensuring it doesn't get cut off if the window size changes - even in IE9. (Just to clarify: The video needs to keep its original aspect ratio, so black bars are acceptable.)
Here's what I've attempted so far.
/*CSS*/
#player-overlay {
position: absolute;
display: none;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000
z-index:999;
}
<!--HTML-->
<div id="player-overlay">
<video width="100%" video="100%" style="width:100%, height:100%">
<source src="../static/video/10s.mp4" />
<source src="../static/video/10s.webm" type='video/webm; codecs="vp8, vorbis"' />
<source src="../static/video/10s.ogv" type='video/ogg; codecs="theora, vorbis"' />
</video>
</div>
It looks like I might have to resort to writing a JavaScript solution instead.