Place Div On Top Of Video Using Javascript March 17, 2024 Post a Comment I have several kinds of videos, like this Solution 1: You can do this using pure CSS - no JS required!The HTML<divid="video-container"><iframewidth="420"height="315"src="//www.youtube.com/embed/dQw4w9WgXcQ"frameborder="0"allowfullscreen></iframe><divclass="video-overlay"> Overay Content </div></div>CopyThe CSS#video-container { position:relative; width:420px; } .video-overlay { position:absolute; top:50px; right:50px; background:#000; color:#FFF; } CopySee it in action http://jsfiddle.net/y28Zs/Solution 2: try thishttp://jsfiddle.net/miquelcamps/BJN8x/3/htmlBaca JugaHow To Get Information Like History From Your Browser And Place Them In A Div ElementMultilevel Hierarchical Edge BundlingDynamically Create Object Keys In Ie 11 (expected Identifier, String Or Number, Not A Comma Issue)<video id="embed" width="200" height="200" controls> <source src="http://vjs.zencdn.net/v/oceans.mp4"type="video/mp4"> Your browser does not support the video tag. </video> Copyjavascriptvar vid = document.getElementById('embed'); var width = vid.width; var height = vid.height; var x = vid.offsetLeft; var y = vid.offsetTop; var div = '<div class="overlay" style="height:'+height+'px;width:'+width+'px;left:'+x+'px;top:'+y+'px;">Hello</div>'; document.body.innerHTML += div; Copycss.overlay{ position:absolute; background:red; z-index:99; } CopySolution 3: Please check is it what you want : <div id="adds"> <video id='abd' height="200" width="200" style="border:2px solid" ></video> </div> CopyJavascript ----vid=document.getElementById('abd'); addDiv =document.getElementById('adds'); var width = vid.offsetWidth; var height = vid.height; var x = width/2+ 'px'; var y = height - 12+'px'; var newDiv = document.createElement("div"); newDiv.innerText = "Hello...."; newDiv.style.left = "102px"; newDiv.style.top = "108px"; newDiv.style.position = "absolute"; addDiv.appendChild(newDiv); CopyLive demo : (http://jsfiddle.net/7EhtL/) Share You may like these postsJquery .remove() Not Working For Dynamic FormVaildate Dynamic Added Array Inputs - Jquery ValidateHow To Add Facebook Like And Comments Box To Image JavascriptTurn Multiple Youtube/vimeo Links Into Embedded Players Post a Comment for "Place Div On Top Of Video Using Javascript"
Post a Comment for "Place Div On Top Of Video Using Javascript"