javascript - CSS positioning/resizing html5 video background -
hey wizards of interwebs, i've been pulling hair out past couple of days trying figure 1 out.
i'm trying include fullscreen video background , seems have hit snag.
below image of trying accomplish.
i tried video element iframe. can't div below nest under, when browser window resized.
any or pointers appreciated. closest i've gotten min-width/height still leaves gap...
what end shws in 2nd img. video resizes browser , there's gap below it
to prevent problem need this:
css:
.div1{ background-color: red; height: 100%; position: relative; overflow: hidden;} .div2{ background-color: black; height: 100%;} video{ position: absolute; height: 100%; width: 100%; margin: 0; padding: 0; top: 0; bottom:0; right: 0; left: 0;}
and put video inside div1:
<div class="div1"> <video autoplay>...</video> </div> <div class="div2"> </div>
it don't allow video element show @ overflow. , div1 height:100% , div2 height:100%.
if fit video div1 add
object-fit: cover;
to video tag.
ie doesn't support object-fit
Comments
Post a Comment