Answer the question
In order to leave comments, you need to log in
Block with z-index goes beyond the background, what's the problem?
Tell me if it's not difficult, what is the problem. I really don't understand how z-index works. There is a block with a background, there is another block in it, which is set to position: relative and z-index: 10;. In this block, the picture, which is set to position: absolute; and z-index: 1; I need half of this picture to be behind the block.
I read several articles on the z-index account, and according to the plan, everything should work, but nothing works. I played with numbers in different ways, and set minuses and pluses and percentages. And I saw at least some movement when I asked the parent z-index: 10%; and child z-index: -1; Although I didn’t read about percentages anywhere, at least it somehow worked. But when you set -1 then the picture becomes the background. In short, I don't know what to do anymore. Help ))
Here is the code https://codepen.io/rebrikover/pen/JLyMpp
Answer the question
In order to leave comments, you need to log in
The problem is that a child element cannot have a z-index less than the parent element, as in your case.
You can implement it in different ways, depending on what and how else you want to place there. Alternatively, change it like this:
.block1 {
/* background: #323232; */
/* z-index: 10; */
}
.block1::after {
content: "";
position: relative;
display: block;
height: 100%;
background: #323232;
}
img {
/* z-index: 1; */
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question