Befeore / After on absolute:position和z-index:1个元素

时间:2016-10-06 12:15:37

标签: css

如何安排:在具有position: absolutez-index: -1的{​​{1}}和position: absolute的伪元素之前或之后:z-index: 1#element { position: absolute; z-index: 1; width: 100px; height: 100px; background-color: blue; } #element::after { content: ""; width: 150px; height: 150px; background-color: red; position: absolute; top: 20px; z-index: -1; }

https://jsfiddle.net/x5x6ye97/2/



<div id="element"></div>
&#13;
Annie      101   56   89
Joy        102   78   56
rinken     103   45
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

嗯,我觉得你想要实现这个......

以下是工作代码 -

#element { 
    position: relative;  /* optional */
    width: 100px;
    height: 100px;
    background-color: green;
}

#element::after {
    content: "";
    width: 150px;
    height: 150px;
    background-color: yellow;
    position: absolute;
    z-index: -1;  
}
<div id="element"></div>

希望这会对您有所帮助:)