javascript - Wrap a div over a video -
javascript - Wrap a div over a video -
this question has reply here:
make div's size , position same video's 2 answersi have html5 video width of 100% , height of 100% , , want wrap div fit size , position of video (not video tag, video (see screenshot below) using necesary.
[see fiddle]
html:
<div id="wrapper"></div> <video id="vid" controls preload="none" width="100%" height="100%" poster="http://video-js.zencoder.com/oceans-clip.png"> <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4'/> <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm'/> <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg'/> </video>
css:
#wrapper{ width: 2px; height: 2px; border: solid 2px red; position: absolute; }
js (jquery):
setinterval(function(){ $("#vid").height($(window).height() - $("header").height() - 7); /*there header , bunch of other stuff in original code*/ }, 10);
this first question here if need i'll glad answer. thanks.
calculation of height , width of video using video's aspect ratio seems necessary. fiddle puts height on video element (set 264), not same question's code sample. more appropriate question?
that beingness said, perhaps can effort calculate proper height , top css value of wrapper, assuming video width landscape (full window width):
javascript:
var vidratio = $("#vid").height()/$("#vid").width(); setinterval(function(){ $("#vid").height($(window).height() - $("header").height() - 7); var width = $(window).width()-20; // abitrary 20 pixels business relationship border/margin/padding? $("#wrapper").css({ 'width': width, 'height':width*vidratio, 'top':($(window).height()-width*vidratio)/2 }); /*there header , bunch of other stuff in original code*/ }, 10);
css:
#wrapper { width: 2px; height: 2px; border: solid 2px red; position:absolute; }
http://jsfiddle.net/lsubirana/1ly0f5cx/
it's not perfect may help.
javascript css html5 video
Comments
Post a Comment