Z-indexnot working on pseudo-elements
Hello team, I am working on some pseudo-elements with backgroung-images, and my problem is that no matter if i set the ::before and the ::after with pisition: absolute and z-index lower than the parent element, they don't go under the parent element covering my patent element. Why is that? And how can i solve it?
3 Replies
Kevin Powell
YouTube
Solve your z-index issues | z-index and stacking context explained
While it would be handy (at times) for z-index to be a global value, the truth is, it isn't. It's related to its local stacking context, which can be created by a parent with its own z-index value, but also by other properties such as transform, opacity, and many more, which is something most people aren't aware of.
In this video, I look at wha...
yeah, the parent there is creating a new stacking context with the
z-index
on there, so there's no way the children can escape it.Hi Kevin, the code snippet i have given has a parent div and I had to give that parent div a
position: relative
and a z-index:0
to make it work as ai want it to. Now the pseudo elements are behind the .tartkozep div background image. It is weird though that it works like this, but it's ok now
Thank you for your and @b1mind help