简体   繁体   English

如何解决IE7中复杂的Z-index问题

[英]How to solve a complicated Z-index issue in IE7

I am having a trouble working on the z-index of IE7. 我在处理IE7的z-index时遇到麻烦。 I have done tons of research and still can't fix my problem. 我已经做了大量研究,但仍然无法解决我的问题。

I have 我有

4 buttons with drop down menu. The dropdown menu has absolute position and have z-index of 9999;

 ----     ----    -----    -----
|    |   |    |  |     |  |     |
 ----     ----    -----    -----
dmenu    dmenu    dmenu    dmenu

another 4 buttons with popup images that pop on top of the button. The images also have absolute position and have z-index of 9999;

 pop img   pop img  pop img     pop img
 ----       ----    -----      -----
|    |     |    |  |     |    |     |
 ----       ----    -----      -----



 I want dropdown menu will cover the buttons below and and pop images will cover the button above. 

Everything works fine in Chrome and FF but IE. 在Chrome和FF中,但在IE上,一切正常。 The dropdown menu will show behind the bottom buttons instead of covering them. 下拉菜单将显示在底部按钮的后面,而不是覆盖它们。

The top buttons are the parents of dropdown menu and bottom buttons are the parents of pop images. 顶部按钮是下拉菜单的父级,底部按钮是弹出图像的父级。

I have tried 我努力了

1.set relative position on top and bottom buttons. 1.在顶部和底部按钮上设置相对位置。

2.run this script 2.运行此脚本

   var zIndexNumber = 1000;
       // Put your target element(s) in the selector below!
       $("div").each(function() {
               $(this).css('zIndex', zIndexNumber);
               zIndexNumber -= 10;
               console.log($(this));
       });

The above script will fix the dropdown menu to covers the bottom buttons but also make the top buttons cover pop images because pop images have lower z-index. 上面的脚本将修复下拉菜单,使其覆盖底部按钮,但也使顶部按钮覆盖弹出图像,因为弹出图像的Z索引较低。

I am very frustrated now and need helps. 我现在非常沮丧,需要帮助。 Thanks so much! 非常感谢!

Try this: Make sure the dropdown's parents have a position:relative. 尝试以下操作:确保下拉菜单的父母有一个position:relative。 IE 6 & IE 7 Z-Index Problem I usually make sure the ul in this case would have a display:block as well. IE 6和IE 7 Z索引问题我通常会确保ul在这种情况下也具有display:block。

The other thing I would do is set the z-index of the parent to a lower number and set the z-index on the page by applying a z-index of 0 to the body. 我要做的另一件事是将父级的z-index设置为较小的数字,并通过将body的z-index设置为0来设置页面上的z-index。

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

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