简体   繁体   English

带有 z-index 的背景中的 iframe,没有菜单控件?

[英]iframe in background with z-index, no menu controls?

I am developing a webpage which puts an iframe as a background due to other div elements "playing with it".我正在开发一个网页,由于其他 div 元素“玩弄它”,因此将 iframe 作为背景。 Using z-index, it is in the background area, visible, but i need to be able to control it, and the controls that are usually present are missing.使用z-index,它在背景区域,可见,但我需要能够控制它,而通常存在的控件丢失了。 Here's the main code:这是主要代码:

Here's the html:这是html:

<div class="bg-about">
  <iframe src="https://player.vimeo.com/video/54960454?title=0&amp;byline=0&amp;portrait=0;autoplay=1"></iframe>
  <div id="iframe"></div>
</div>

Here's the css:这是CSS:

iframe {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
#iframe {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
}

Any ideas?有任何想法吗? I really need the controls.我真的需要控件。 Note: the background is not actually behind anything, but due to formatting, it must be in a background.注意:背景实际上并不在任何东西后面,但由于格式的原因,它必须在背景中。 And I'm not sure why its displayed wrong.而且我不确定为什么它显示错误。

You are covering the video with the #iframe, so you can't rollover video to view controls.您正在使用 #iframe 覆盖视频,因此您无法翻转视频以查看控件。 I just swapped the z index of video to 2 and #iframe to 1. You were just covering video with div by mistake.我只是将视频的 z 索引交换为 2,将 #iframe 交换为 1。您只是错误地用 div 覆盖了视频。

iframe {
 position: absolute;
 z-index: 2;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
 }
 #iframe {
     position: absolute;
     z-index: 1;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     overflow: auto;
}

here is link: https://jsfiddle.net/keinchy/asga90Lg/这是链接: https : //jsfiddle.net/keinchy/asga90Lg/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM