【发布时间】:2016-11-15 18:43:13
【问题描述】:
在堆栈上阅读some answers 后,我设法为我的 youtube 视频制作了一个 div 叠加层。描述说它可以让我在构造的 div 中添加尽可能多的 div,这对我来说很有意义。
但是,我放在那里的第二个 div 正在下推我的视频。我尝试调整位置和 z-index 但这没有帮助。为什么只有一个 div 将视频向下推?父 div 不应该确保他们都将鼠标悬停在视频上吗?
(顺便说一句,后面会用jquery隐藏第二个div,这样第一个div就可以点击打开了。)
我将视频叠加层包装在容器中:
.outer-container {
width:68%;
height:575px;
margin-left:2%;
background-color:#97D3A3;
display:inline-block;
}
.inner-container {
display: inline-block;
position: relative;
width: 100%;
height: 100%;
}
.video-overlay {
width:100%;
}
.video {
width: 100%;
height: 100%;
}
.overlaycontent {
width:100%;
height:100%;
background-color:#fff;
color:#000;
position: relative;
z-index: 98;
}
.overlayinfo {
position: relative;
z-index: 99;
height: 0px;
border-top: 4px solid #F1860B;
width:100%;
max-width:816px;
text-align:center;
}
.overlayinfo img {
margin:0px auto;
width:53px;
}
这是我的 HTML:
<div class="outer-container">
<div class="inner-container">
<div class="video-overlay">
<div class="overlayinfo">
<a href="#" class="infotrigger"><img src="#"></a>
</div>
<div class="overlaycontent">
Lorem ipsum dolor sit amet
</div>
</div>
<iframe class="video" width="100%" height="100%" src="https://www.youtube.com/embed/6ttrZ11csfI?autoplay=1&controls=0&loop=1&playlist=6ttrZ11csfI&showinfo=0&modestbranding=1" frameborder="0"></iframe>
</div>
</div>
这是一个查看完整图片的小提琴: https://jsfiddle.net/boe5xLte/2/
【问题讨论】:
-
如果我理解正确你错过了:
.overlaycontent { height: 0;}或更好地使用position: absolute