admin管理员组文章数量:1355532
I am trying to overlay 2 video elements, where one lies directly on top of another. Obviously, the one on top will be smaller than the other such that both are visible. So far, the only things I have been able to find are overlaying text over the video, but most of the time the examples I have seen used hardcoded distances from the top of the page to acplish this.
Here's what I have tried:
HTML:
<div class='video-container'>
<video class='userVideo' id="localVideo" autoplay></video>
<video class='peerVideo' id='peerVideo' autoplay></video>
</div>
CSS:
.userVideo {
height: 200px;
width: 200px;
float: left;
border:5px solid orange;
position: absolute;
top: 100px;
}
.peerVideo {
height: 200px;
width: 200px;
border:5px solid blue;
}
So far, the only thing I have been able to achieve is a text div overlapping a single video. Is there a way to overlap 2 videos or even nest a video within another?
I am trying to overlay 2 video elements, where one lies directly on top of another. Obviously, the one on top will be smaller than the other such that both are visible. So far, the only things I have been able to find are overlaying text over the video, but most of the time the examples I have seen used hardcoded distances from the top of the page to acplish this.
Here's what I have tried:
HTML:
<div class='video-container'>
<video class='userVideo' id="localVideo" autoplay></video>
<video class='peerVideo' id='peerVideo' autoplay></video>
</div>
CSS:
.userVideo {
height: 200px;
width: 200px;
float: left;
border:5px solid orange;
position: absolute;
top: 100px;
}
.peerVideo {
height: 200px;
width: 200px;
border:5px solid blue;
}
So far, the only thing I have been able to achieve is a text div overlapping a single video. Is there a way to overlap 2 videos or even nest a video within another?
Share Improve this question asked Apr 3, 2015 at 5:02 puopgpuopg 5737 silver badges17 bronze badges 1- Try using css z-index property. – stanze Commented Apr 3, 2015 at 5:09
1 Answer
Reset to default 8What you need to do is set .video-container
to position: relative;
, and then make the two videos position: absolute;
this will simply overlay your videos on top of each other and encapsulate them in .video-container
here's a fiddle with the changes to your css
本文标签: javascriptOverlaying an HTML5 video element over another video elementStack Overflow
版权声明:本文标题:javascript - Overlaying an HTML5 video element over another video element. - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744006320a2574766.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论