css - IE7 Z-Index 问题

标签 css cross-browser internet-explorer-7 internet-explorer-6

在我目前工作的网站上,边栏中有一个嵌套的无序列表,当 <li>从这个列表中悬停,它显示(以前隐藏的) child <ul> .这在除 IE 7+6 之外的所有浏览器中都可以正常工作。在这些浏览器中,弹出窗口 <ul>显示在 <li> 下方上面列表的。知道为什么要这样做吗?

我的 CSS 如下:

div#sidebar-products {
    border-bottom: 3px solid #D31245;
    height: 297px;
}
    div#sidebar-products h2 {
        font-size: 1.5em;
        border-bottom: 0;
        padding: 5px 0 12px 0;
        color: #D31245;
    }
    div#sidebar-products ul{
        z-index: 0;
    }
        div#sidebar-products li{
            position: relative;
        }
            div#sidebar-products ul li a,
            div#sidebar-products ul li a:visited
            {
                display: block;
                border-bottom: 1px solid #eeeeee;
                text-decoration: none;
                padding: 7px 10px 7px 20px;
                color: #6b6869;
                background: #fff url(/img/raquo-red.png) 7px center no-repeat;
            }
            div#sidebar-products li a:hover,
            div#sidebar-products li a:focus,
            div#content-holder div#sidebar-products li.active a
            {
                background-image: url(/img/raquo-white-red.png);
                background-color: #D31245;
                color: #fff;
            }   
        div#sidebar-products ul ul{
            display: none;
            padding-left: 10px;
            position: absolute;
            margin-top: -1px;
            z-index: 9999 !important;
            border: 1px solid #D31245;
            background: #f3f3f3;
            width: 247px;
        }
            div#sidebar-products ul li ul li {
                margin-bottom: 0;
                position: static !important;
                z-index: 500;
            }
                div#site-holder div#content-holder div#sidebar-products ul ul li a {
                    background: #fff url(/img/raquo-red.png) 10px center no-repeat;
                    padding-left: 24px;
                    color: #949494;
                }
                div#site-holder div#content-holder div#sidebar-products ul li ul li a:hover,
                div#site-holder div#content-holder div#sidebar-products ul li ul li a:focus
                {
                color: #D31245;
                background-color: #fff;
            }

最佳答案

我想您可能遇到过这样的错误,即 IE 不在文档级别处理 z-index,而是在容器级别处理。我忘记了确切的错误细节,它通常通过添加/删除位置来修复:我相信相对于共享祖先元素。

尝试这些以获得更多细节:

关于css - IE7 Z-Index 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3959728/

相关文章:

html - 位置 : absolute; inside dynamic position: relative; element

html - 在 Internet Explorer 7 中使用 z-Index 定位 div

css - 如果需要自动调整 mat-table 行

javascript - 将 Javascript keyCode 转换为非美国键盘布局的 charCode(即 azerty)

html - CSS 列样式仅适用于 Chrome 中的一列

javascript - 使用 jquery IE 10 与 Chrome 的缓慢/滞后单选按钮

css - 位置 :relative item WAS out-of-screen 时的 IE7 滚动条

javascript - 如何在图片的两个区域悬停?

jquery - 我可以用cycle()来做到这一点吗?

css - 将噪声图像混合到 CSS 按钮中的目的是什么?