添加位置后IE7 z-index不起作用?

时间:2013-09-18 17:14:53

标签: html css

IE7 z-index即使我添加位置也不起作用:absoluterelative

还有其他解决方案吗?我添加其他div较低的z索引但不起作用

.gallery {
    background-color: #F4F4F4;
    display: block;
    min-height: 300px;
    padding: 20px 10px;
    position: absolute;
    right: -44px;
    top: 70px;
    width: 980px;
    z-index: 3000;
    display: none;
}
.sub_menu {
    background-color: #F4F4F4;
    float: left;
    height: 21px;
    padding: 40px 35px;
    position: relative;
    top: 10px;
    width: 930px;
    z-index: 1000;
}

2 个答案:

答案 0 :(得分:1)

使用z-index和IE时,有时需要使用!important

.gallery {
    background-color: #F4F4F4;
    display: block;
    min-height: 300px;
    padding: 20px 10px;
    position: absolute;
    right: -44px;
    top: 70px;
    width: 980px;
    z-index: 3000 !important;
    display: none;
}
.sub_menu {
    background-color: #F4F4F4;
    float: left;
    height: 21px;
    padding: 40px 35px;
    position: relative;
    top: 10px;
    width: 930px;
    z-index: 1000 !important;
}

答案 1 :(得分:0)

!important 

应该用作最后的结果。

请先手动

body{
    z-index: -1
} 

.gallery {
    background-color: #F4F4F4;
    display: block;
    min-height: 300px;
    padding: 20px 10px;
    position: absolute;
    right: -44px;
    top: 70px;
    width: 980px;
    z-index: 2;
    display: none;
 }

.sub_menu {
    background-color: #F4F4F4;
    float: left;
    height: 21px;
    padding: 40px 35px;
    position: relative;
    top: 10px;
    width: 930px;
    z-index: 1;
}