相关疑难解决方法(0)

::之前的伪元素堆叠顺序问题

当静态定位时,:: before伪元素在孩子的内容之前堆叠(z-index),但是在孩子的背景之后.任何人都可以解释为什么甚至如何发生这种情况,或者这是否是所有主流浏览器都存在的问题?

<style>
div { background-color:yellow; width:400px; }
div::before { background-color:red; content:"div::before"; }
div::after { background-color:green; content:"div::after"; }
div p { background-color:blue; color:white; margin:-15px 0; padding:0; }
</style>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed tellus sed tellus sodales hendrerit tristique et elit.</p>
</div>
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/funkyscript/ALrgf/

css z-index pseudo-element

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

pseudo-element ×1

z-index ×1