css更改z-index是不可影响的

时间:2014-06-16 23:42:55

标签: html css css3

这是结果: enter image description here

了解链接如何覆盖数字

我尝试更改before元素的z-index并继续将其放大,但该行保持在数字之上,

你可以帮忙吗? 该行的代码是

#progressbar li:after {
    content: '';
    width: 100%;
    height: 2px;
    background: black;
    position: absolute;
    left: -50%;
    top: 9px;
    z-index: 0; /*put it behind the numbers*/
}

这是一个jfiddle

http://jsfiddle.net/FkSH5/

1 个答案:

答案 0 :(得分:4)

这是因为你的::before伪元素(顺便说一下,你应该使用::表示伪元素而:表示伪类)正在被{{覆盖1}}伪元素。

解决方案是将::after伪元素设置为相对定位(如果不使用相对定位,将忽略z-index属性) -index高于::before对应物,即:

::after

请在此处查看修改过的小提琴:http://jsfiddle.net/teddyrised/FkSH5/1/