为什么 jquery Mega 菜单显示在 IE7 和 9 中我的图像后面?
我有一个网页,顶部有一个 jquery Mega Menu ,下面有一个 jqGrid它。当我将鼠标悬停在菜单上时,子菜单会弹出,但它显示在 jqGrid“后面”。我尝试进入 dcMegaMenu.css 并添加:
z-index:2000;
此图像是直接拍摄的 离开示例页面,可以重现此问题
到处都是,但它仍然显示在图像后面?有什么建议吗?
I have a webpage with a jquery Mega Menu at the top and then there is a jqGrid right below it. When I hover over the menu, the submenu pops up but it shows up "behind" the jqGrid. I tried going into the dcMegaMenu.css and adding:
z-index:2000;
this image is taken directly off of the examples page where this issue is reproducable
all over the place but it still shows up behind the images? Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
此问题是由 IE7 错误引起的。从链接的答案中引用我自己的话:
在 IE9 中发生同样问题的唯一方法是 IE9 以兼容模式显示页面(或者使用 IE7 模式)。按 F12 打开开发人员工具以查看正在使用哪种模式。
要在 页面上的 IE7 中修复此问题,您需要链接到,需要在
.demo-container
上添加position:relative; z 索引:1;
。如果您无法将此修复翻译到您的实际页面,如果您提供实际页面的链接(或者准确的测试用例:http://jsfiddle.net/ / http://jsbin.com/)。
以下是 IE7 模式下 IE9 的屏幕截图,并使用开发人员工具应用了修复:
This problem is caused by an IE7 bug. Quoting myself from the linked answer:
The only way this same problem can be happening in IE9 is if IE9 is displaying the page in Compatibility mode (or is otherwise using IE7 mode). Hit F12 to bring up Developer Tools to see which mode is being used.
To fix this problem in IE7 on the page you linked to, you need to on
.demo-container
addposition: relative; z-index: 1;
.If you're unable to translate this fix to your actual page, I can help further if you provide a link to your actual page (or, an accurate test case: http://jsfiddle.net/ / http://jsbin.com/).
Here's a screenshot from IE9 in IE7 mode with the fix applied using Developer Tools:
如果没有显示任何代码,我能想到的是,如果元素未定位,z-index 将什么都不做:
参考:https://developer.mozilla.org/en/Understanding_CSS_z-index
有关变换和 z-index 的部分: https://stackoverflow.com/a/7765214/137626
Without any code shown, all I can think of is that z-index will do nothing if the element isn't positioned:
Reference: https://developer.mozilla.org/en/Understanding_CSS_z-index
For the part about transform and z-index: https://stackoverflow.com/a/7765214/137626
可以使用 z-index:1; 来解决,但是对于定位的元素。正如 w3school.com 所解释的,z-index 只能与定位元素一起使用。因此,如果您将超级菜单的列表项设置为相对位置
position:relative;
并使用z-index :1;
会起作用。It could be solved using the
z-index:1;
But with regards to the positioned element. as explained by w3school.com z-index can only be used with positioned elements.So, if you set the mega Menu's list items in a relative positionposition:relative;
and usez-index:1;
will work.通过使用位置:绝对;只需添加 z-index:1;因为堆栈顺序较大的元素总是在堆栈顺序较低的元素前面,所以 z-index 可以用来控制堆栈顺序,并且仅用于定位元素
by using position:absolute; just add a z-index:1; because element with greater stack order is always in front of the one with low stack other , z-index can be used to control the stack order and it is only used on positioned element