z-index 和 iframe 问题 - 下拉菜单
嘿。我的下拉菜单和 iframe 有一个相当令人费解的问题。
我已将 1000 的 z 索引应用于下拉菜单,但是包含 youtube 视频的 iframe 仍然出现在菜单上方。请自行查看以下内容(检查“短代码”菜单):
http://www.matthewruddy.com /demo/?page_id=765
我不明白这是为什么。有人可以帮我吗?如果有帮助的话,这是 CSS:
#jquery-dropdown {
position: absolute;
bottom: 0;
right: 10px;
}
#jquery-dropdown ul {
margin: 0;
padding: 0;
list-style: none;
}
#jquery-dropdown ul li {
margin: 0;
padding: 15px 10px 15px 10px;
position: relative;
float: left;
}
#jquery-dropdown ul li a {
display: block;
text-decoration: none;
font-weight: bold;
font-size: 13px;
color: #707070;
outline: none;
}
#jquery-dropdown ul li ul {
position: absolute;
left: -10px;
top: 46px;
display: none;
background: #f4f4f4;
border: 1px solid #e1e1e1;
border-top: none;
z-index: 1000;
padding: 5px 0;
-moz-box-shadow: 1px 2px 3px #a4a4a4;
-webkit-box-shadow: 1px 2px 3px #a4a4a4;
box-shadow: 1px 2px 3px #a4a4a4;
}
#jquery-dropdown ul li ul li {
margin: 0;
padding: 0;
float: none;
position: relative;
z-index: 1000;
}
#jquery-dropdown ul li ul li a {
width: 180px;
padding: 10px;
z-index: 1000;
}
#jquery-dropdown ul li ul li a:hover {
background: #e0e0e0;
}
Hey. Having a rather puzzling issue with my dropdown menus and iframes.
I have applied a z-index of 1000 to the dropdown menus, however the iframe containing the youtube video still appears above the menu. See for yourself below (check the 'shortcodes' menu):
http://www.matthewruddy.com/demo/?page_id=765
I cannot figure out why this is. Can anyone help me out? Here is the CSS if it helps:
#jquery-dropdown {
position: absolute;
bottom: 0;
right: 10px;
}
#jquery-dropdown ul {
margin: 0;
padding: 0;
list-style: none;
}
#jquery-dropdown ul li {
margin: 0;
padding: 15px 10px 15px 10px;
position: relative;
float: left;
}
#jquery-dropdown ul li a {
display: block;
text-decoration: none;
font-weight: bold;
font-size: 13px;
color: #707070;
outline: none;
}
#jquery-dropdown ul li ul {
position: absolute;
left: -10px;
top: 46px;
display: none;
background: #f4f4f4;
border: 1px solid #e1e1e1;
border-top: none;
z-index: 1000;
padding: 5px 0;
-moz-box-shadow: 1px 2px 3px #a4a4a4;
-webkit-box-shadow: 1px 2px 3px #a4a4a4;
box-shadow: 1px 2px 3px #a4a4a4;
}
#jquery-dropdown ul li ul li {
margin: 0;
padding: 0;
float: none;
position: relative;
z-index: 1000;
}
#jquery-dropdown ul li ul li a {
width: 180px;
padding: 10px;
z-index: 1000;
}
#jquery-dropdown ul li ul li a:hover {
background: #e0e0e0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您想继续使用嵌入 Youtube 视频的
iframe
方法,只需通过查询变量?wmode=transparent
设置 WMODE 即可。下面是一个示例:将变为:
请记住检查 Youtube URL 中是否存在任何已存在的查询变量。如果已经有
?something...
将?wmode=transparent
更改为&wmode=transparent
并将其粘在末尾。If you want to keep using the
iframe
method of embedding Youtube vids, you can simply set the WMODE via query variable?wmode=transparent
. Here's an example:Would become:
Remember to check Youtube URL for any query variables already present. If there already is
?something...
change?wmode=transparent
to&wmode=transparent
and tack it on the end.我将使用
这里有一些更多信息
I would use the embedding of the youtube video using the
<object>
tag and not Iframe. Then, I would use the<param name="wmode" value="transparent">
inside the<object>
. Something like this:Here is some more info
如果 ?wmode=transparent 不起作用,请尝试切换为不透明。这对我来说有效。
样本:
If ?wmode=transparent doesn't work, try switching to opaque instead. That worked in my case.
Sample:
在我的机器(Windows 7 上的 Chrome)上,显示 YouTube 视频的插件是与浏览器内容窗口不同的本机窗口。我认为当插件以这种方式运行时,它会在浏览器中的任何其他内容之上呈现,忽略 CSS z-index 值。
Silverlight 插件有一个设置,可以使其在浏览器内容窗口而不是其自己的本机窗口中运行。您可以尝试为嵌入式 YouTube 播放器找到类似的设置。
On my machine (Chrome on Windows 7) the plugin displaying the YouTube video is a different native window than the browser content window. I think that when a plugin runs this way it renders on top of any other content in the browser, ignoring the CSS z-index values.
The Silverlight plugin has a setting to make it run in the browser content window instead of its own native window. You can try to find a similar setting for the embedded YouTube player.
Flash 并不总是能在所有浏览器上与 z-index 配合良好,但在我的 Firefox 上看起来很好。 http://manisheriar.com/blog/flash_objects_and_z_index <<我认为这可能是您正在寻找的解决方案。
编辑
为什么 IE 中的 Z-Index 不能按照 Flash 影片应有的方式渲染? << stackoverflow 上有类似的问题
Flash doesn't always play nice with z-index on all browsers, looks fine from my firefox. http://manisheriar.com/blog/flash_objects_and_z_index << I think that might be the solution that you're looking for.
Edit
Why doesn't Z-Index in IE render the way it's supposed to over a Flash Movie? << similar issue here on stackoverflow
这是一个 iframe 问题,而不是 z-index 。我遇到的同样问题,我只是将 ?wmode=transparent 添加到 YouTube 嵌入 i 框架 src url 中。就像这样:
That is a iframe issue not a z-index .Same issue i faced i just add the ?wmode=transparent to the YouTube embed i frame src url. Like so: