简体   繁体   English

您将如何解决这个常见的IE Z-index错误的罕见示例?

[英]How would you fix this uncommon example of the common IE Z-index bug?

This may appear to be a common question that has already been answered because it refers to the well-known z-index bug in IE7 and lower. 这似乎是一个已经解决的常见问题,因为它涉及IE7及更低版本中众所周知的z-index错误 However, this situation is somewhat unique; 但是,这种情况有些特殊。

I am using a CSS dropdown menu that uses nested lists for sub menus. 我正在使用CSS下拉菜单,该菜单使用嵌套列表作为子菜单。 I have used this many times on other sites, but usually with the first level being horizontal. 我已经在其他站点上使用了很多次,但是通常第一层是水平的。 In this case, the first level needs to be vertical and the sub menus should fly out rather than drop down. 在这种情况下,第一层必须是垂直的,子菜单应该弹出而不是下拉。

On top of that, the whole thing is complicated because the first level "wraps" to a curve in the design and the menu ul floats to accommodate a different layout on internal pages. 最重要的是,整个过程很复杂,因为第一级“环绕”设计中的曲线,并且菜单ul浮动以适应内部页面上的不同布局。 The floating causes all kinds of problems with apparent solutions, because if the z-index is higher than the content on the page, the links in that content are covered by top level menu items. 浮动会带来各种明显的解决方案问题,因为如果z索引高于页面上的内容,则该内容中的链接将被顶级菜单项覆盖。

Anyway, with a lot of patience I've gotten it to work perfectly, except in IE7 and lower. 无论如何,除了IE7及更低版本外,我已经耐心地使其完美运行。 The problem I'm having is that IE wants to put the sub-menus underneath the top level menu items (This is the expected behavior for IE, I understand that). 我遇到的问题是IE希望将子菜单放在顶层菜单项的下面(这是IE的预期行为,我知道)。 But, since the top level items are on a curve, some of the flyout menus end up being overlapped by top level items. 但是,由于顶级项目在曲线上,因此某些弹出菜单最终被顶级项目覆盖。

As an, admittedly awful, fix, I used the star hack in my CSS to add padding to the flyout menus. 作为一个令人敬畏的解决方法,我在CSS中使用了star hack来向弹出菜单添加填充。 This makes them functional, but doesn't actually address the issue or look appealing. 这使它们起作用,但实际上并不能解决问题或看上去很吸引人。

So, view the site , and let me know if you have any ideas. 因此,请查看该网站 ,如果您有任何想法请告诉我。 Thanks! 谢谢!

You will want to take all the li at the top level and set their z-index values incrementally lower as you go down the page. 您需要将所有li放在顶层,并在向下浏览时逐渐降低其z-index值。 For instance, starting from the top "Property Search", assign z-index values of 99, 98, 97, etc. This should make it so the child items (submenus) of each li will be on a higher z-index stack than the root items following them on the page. 例如,从顶部的“属性搜索”开始,分配z-index值分别为99、98、97等。这应该使每个li的子项(子菜单)位于比其更高的z-index堆栈上。页面上紧随其后的根项目。

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

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