【发布时间】:2021-11-28 15:16:58
【问题描述】:
为什么我的::before 伪元素不在它的父元素后面?我正在创建一个新的堆叠上下文并添加一个 -1 的 z-index。
.panda {
position: relative;
border: 1.5vmin solid black;
width: 45vmin;
height: 45vmin;
border-radius: 50%;
background: #fff;
z-index: 2;
&:before {
content: '';
position: absolute;
z-index: -1;
width: 15vmin;
height: 15vmin;
background: black;
border-radius: 50%;
top: -4vmin;
left: -2.1vmin;
box-shadow: 30vmin 0 #000;
}
}
【问题讨论】:
-
你熊猫的眼睛和鼻子很好看
-
谢谢,希望我能把耳朵放在他脑后。
-
你能告诉我这条线
border-radius: 50% 50% 48% 52% / 21% 21% 79% 79%;。哪个部分确实创造了耳朵 -
创建耳朵的部分是.panda:before
-
是的,发现解决方案是在 CSS 中使用
::after(你了解 CSS),但你能告诉我border-radius: 50% 50% 48% 52% / 21% 21% 79% 79%;
标签: css pseudo-element