IE7 中菜单悬停 z-index 错误

发布于 2025-01-07 18:29:44 字数 4662 浏览 0 评论 0原文

(已解决)

如果您查看此 wip,您会发现菜单悬停状态不会覆盖下面的内容,我不知道为什么会发生这种情况,并且我尝试将 z-index 值添加到 ul 的大部分部分树,包括最外面的导航标签 -

http://staffanestberg.com/lesmarket2/product.php

我是什么 丢失的?

如果更容易的话,这里是特别的部分 -

<div id="menu-wrapper">
                <ul id="menu">
                    <li><a href="#">New arrivals</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Designers</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Clothing</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Shoes </a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Accessories</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Blog</a></li>
                    <li><a href="#">Sale</a></li>
                </ul>
            </div>

header nav #menu-wrapper {
  position: relative;
  z-index: 80;
  width: 625px;
  height: 31px;
  text-align: center;
  background: transparent url(../images/stripe-menu.gif) no-repeat;
}
header nav #menu-wrapper a,
header nav #menu-wrapper a:active,
header nav #menu-wrapper a:visited,
header nav #menu-wrapper a:hover {
  color: #fff;
}
header nav #menu-wrapper #menu {
  position: relative;
  z-index: 81;
  margin: 6px 0 0 0;
  display: inline-block;
  zoom: 1;
  *display: inline;
}
header nav #menu-wrapper #menu li {
  position: relative;
  z-index: 82;
  height: 20px;
  margin: 0 20px 0 0;
}
header nav #menu-wrapper #menu ul li:hover a,
header nav #menu-wrapper #menu li:hover li a {
  background: none;
}
header nav #menu-wrapper #menu li:hover > ul {
  display: block;
}
header nav #menu-wrapper #menu ul {
  padding: 10px 15px 10px 15px;
  display: none;
  width: 140px;
  height: 200px;
  position: absolute;
  top: 20px;
  left: -15px;
  text-align: left;
  z-index: 90;
  background-color: #000;
  background-color: rgba(0, 0, 0, 0.85);
}
header nav #menu-wrapper #menu ul li:first-child {
  border-top: 1px dotted #fff;
}
header nav #menu-wrapper #menu ul li {
  float: none;
  margin: 0;
  line-height: 18px;
}
header nav #menu-wrapper #menu:after {
  content: ".";
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0;
}
header nav #menu-wrapper html[xmlns] #menu {
  display: block;
}

(Solved)

If you look at this wip you'll see that the menu hover states doesn't overlay the content below, I have no idea why this is happening and I've tried adding z-index values to most parts of the ul tree, including the outer most nav tag -

http://staffanestberg.com/lesmarket2/product.php

What am I missing?

If it's easier here are the parts in particular -

<div id="menu-wrapper">
                <ul id="menu">
                    <li><a href="#">New arrivals</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Designers</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Clothing</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Shoes </a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Accessories</a>
                        <ul>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                            <li><a href="#">Lorem ipsum</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Blog</a></li>
                    <li><a href="#">Sale</a></li>
                </ul>
            </div>

header nav #menu-wrapper {
  position: relative;
  z-index: 80;
  width: 625px;
  height: 31px;
  text-align: center;
  background: transparent url(../images/stripe-menu.gif) no-repeat;
}
header nav #menu-wrapper a,
header nav #menu-wrapper a:active,
header nav #menu-wrapper a:visited,
header nav #menu-wrapper a:hover {
  color: #fff;
}
header nav #menu-wrapper #menu {
  position: relative;
  z-index: 81;
  margin: 6px 0 0 0;
  display: inline-block;
  zoom: 1;
  *display: inline;
}
header nav #menu-wrapper #menu li {
  position: relative;
  z-index: 82;
  height: 20px;
  margin: 0 20px 0 0;
}
header nav #menu-wrapper #menu ul li:hover a,
header nav #menu-wrapper #menu li:hover li a {
  background: none;
}
header nav #menu-wrapper #menu li:hover > ul {
  display: block;
}
header nav #menu-wrapper #menu ul {
  padding: 10px 15px 10px 15px;
  display: none;
  width: 140px;
  height: 200px;
  position: absolute;
  top: 20px;
  left: -15px;
  text-align: left;
  z-index: 90;
  background-color: #000;
  background-color: rgba(0, 0, 0, 0.85);
}
header nav #menu-wrapper #menu ul li:first-child {
  border-top: 1px dotted #fff;
}
header nav #menu-wrapper #menu ul li {
  float: none;
  margin: 0;
  line-height: 18px;
}
header nav #menu-wrapper #menu:after {
  content: ".";
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0;
}
header nav #menu-wrapper html[xmlns] #menu {
  display: block;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好多鱼好多余 2025-01-14 18:29:44

尝试向您的 #menu-wrapper 添加一个位置:相对/绝对(最适合的)和 z 索引

  • IE7 喜欢最上面的父级具有明确定义的 z 索引允许其子元素与其他元素重叠(具有较低的 z 索引)

  • IE7不喜欢rgba(您的ul 元素)背景颜色。使用后备颜色:

.

   header nav #menu-wrapper #menu ul{
       background: rgb(0, 0, 0); /* The Fallback */
       background: rgba(0, 0, 0, 0.85);
       /* ... */
    }

Try to add to your #menu-wrapper a position: relative / absolute (what best suits) and a z-index

  • IE7 likes when the most top parent has a z-index well defined to allow it's children to overlap other elements (with lower z-index)

  • IE7 does not like the rgba (your ul elements) background color. Use a fallback color:

.

   header nav #menu-wrapper #menu ul{
       background: rgb(0, 0, 0); /* The Fallback */
       background: rgba(0, 0, 0, 0.85);
       /* ... */
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文