IE 下拉 z-index 错误
我在 IE(6 和 7)下遇到下拉菜单问题。
http://www.amaconsulting.pl/promocje.html
如您所见,下拉菜单隐藏在 IE 中主要内容区域的后面。
这是一个已知的错误,一般建议是为标题和内容区域设置 z-index,以便 IE 知道它们的“位置”,如下文章中所述:http://bit.ly/coSPcI
我已将 .header div 的 z-index 设置为 20,将 .featured、.content、.primary、.main 设置为 1,尝试找到正确的 div 来解决问题。虽然下拉列表不再隐藏在 .featured div 后面,但它仍然隐藏在主要内容 div 后面(.primary 或 .main,.secondary 都可以)。
这些 div 的 z 索引设置在单独的样式表(即 .css)中,以防有人查找它们。
如果有人可以提供一些建议,我将非常感激。
I'm having a problem with a dropdown menu under IE (6 and 7).
http://www.amaconsulting.pl/promocje.html
As you can see, the dropdown hides behind the main content area in IE.
It's a known bug and general advice is to set a z-index for header and content areas, so IE knows their "place", explained in the article here: http://bit.ly/coSPcI
I've set the z-index of .header div to 20 and .featured, .content, .primary, .main to 1, trying to find the right div to fix the problem. While the dropdown stopped hiding behind the .featured div, it still hides behind the main content divs (either .primary or .main, .secondary is fine).
The z-indexes for these divs are set in a separate stylesheet, ie.css, in case someone'll be looking for them.
If someone could provide some advice, I'd be very grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的原始解决方案在这里 - 瑞士信贷网站。这可行,但使用了复杂的 z-index 解决方案。
这是非常简单和改进的解决方案 - Jeyjoo 库存图片库
这适用于 IE6+、firefox、opera、safari 和 chrome
解决方案
HTML
CSS
为什么它有效
告诉 IE 这两个 div 如何相互关联。
Ok originale solution here - Swiss credit website. This works but uses a complicated z-index solution.
Here is very simple and improved solution here - Jeyjoo stock image gallery
This works in IE6+, firefox, opera, safari and chrome
Solution
The HTML
The CSS
why it works
You have to tell IE how the two divs relate to one another.
在 IE 中,如果绝对定位元素具有 z 索引,那么它包含相对定位元素必须指定 z 索引 (z-index:1),以便绝对定位元素能够出现在其他相对定位元素之上。
所以我认为你需要给你的 ul.nav 一个 z-index 1。我实际上在 我的博客。
更新:
因此,如果我将隐藏 ul 的可见性样式更改为可见,只要 ul.nav 具有正 z-index 值,它就会出现在 div 上方。因此,我认为这与 JS 从隐藏的 UL 渲染下拉菜单的方式有关。除非我有你所有的 HTML/CSS/JS,否则我无法真正解决这个问题,所以我只能为你指出正确的方向,我认为理解 此页面会对您有很大帮助。
In IE if an absolutely positioned element has a z-index then it’s containing relatively positioned element must specify a z-index (z-index:1) in order for the absolutely positioned element to be able to appear on top of other relatively positioned elements.
So I think that you need to give your ul.nav a z-index of 1. I actually wrote about this on my blog.
Updated:
So if I change the visibility style of the hidden ul to visible it appears above the div as it should as long as ul.nav has a positive z-index value. Therefore, I think that this has something to do with the way your JS renders the dropdown menu from that hidden UL. Unless I have all your HTML/CSS/JS I can't really solve this so I can only point you in the right direction and I think that understanding this page will help you a lot.
我在子菜单上管理了 z-index 工作 - Chkredit - 瑞士信用网站
适用于所有版本的 IE,并且很轻且 100% CSS(无 JavaScript)。
IE 没有正确使用 z-index。
检查网站 CSS 代码中的 z-index。您需要将 z-index -1 放在菜单隐藏的项目上。
我现在正在为自己的图片库解决完全相同的问题(转到“顶部图片”页面) - jeyjoo 图像画廊。当我解决这个问题时,我将在这里发布完整的解决方案。
I managed a z-index work around here on a submenu - Chkredit - swiss credit website
Works in all versions of IE and is light and 100% CSS (no javascript).
IE does not use z-index correctly.
Check the z-index's in the CSS code of the website. You will need to put a z-index -1 on the items your menu is hiding behind.
I working on exactly the same problem for my own image gallery right now (go to "top image" page) - jeyjoo image gallery. When I sort this one out, I will post the full solution here.