0

我有定位问题。有一个容器 div,其中包含另一个 div 和一个标签(两者都分开)我需要一个标签来覆盖第二个 div,但是当我使用 z-index 时它似乎不起作用:

这是jsFiddle

http://jsfiddle.net/7YQhu/

和代码

.container{
    width: 100%; 
    background: yellow; 
    opacity: 0.4; 
    height: 130px;
    position:absolute;
}

.inner {
    position: absolute;
    background: red;
    opacity: 0.5;  
    height: 100px;
    width: 100%;
    margin: 15px 0;
}

.inner-link {
    margin:15px auto;
    background:blue;
    display:block;
    width:100px;
    height: 100px;

    z-index: 99!important;  
}
4

3 回答 3

4

<a>通过给它一个位置值而不是默认值来为它创建一个堆叠上下文,static

.inner-link {
    position: relative;
}

http://jsfiddle.net/Adrift/7YQhu/1/

于 2013-05-08T14:23:03.157 回答
1

设置.inner-link也有position:relative;

于 2013-05-08T14:23:14.110 回答
0

添加位置:相对;到内部链接类。

于 2013-05-08T14:26:11.880 回答