IE7中的菜单悬停z-index错误

时间:2012-02-21 19:44:45

标签: css internet-explorer-7

(解决)

如果你看看这个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;
}

1 个答案:

答案 0 :(得分:1)

尝试将#menu-wrapper添加到您的位置:相对/绝对(最适合的)和z-index

  • IE7喜欢当最顶级父母的z-index定义得很好,允许孩子与其他元素重叠(z-index较低)

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

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