Here's the problem in the form of a fancy picture (isn't it beautiful?):
Each rectangle is a div tag and I'll refer to them by their colours. Black is the main content of the page and has to be below red which is the footer. However I have an image (green) within red which extends over the text in black but must always lie below the text. The text in black is contained within a span tag (but this could be a div as well if it needs to be).
My question is, is it possible to give black a z-index of, say, 1; red a z-index of 2; green a z-index of 3; and the text a z-index of 4?
This would make the above picture possible. However, browsers won't allow a child element to have a higher z-index than its parent so the above is not possible. The text always has an inherited z-index of 1, and therefore lies below green.
Is there a workaround?
P.S. I realise this can be a bit confusing to understand, hence the picture.
Question
Nick Brunt
Here's the problem in the form of a fancy picture (isn't it beautiful?):
Each rectangle is a div tag and I'll refer to them by their colours. Black is the main content of the page and has to be below red which is the footer. However I have an image (green) within red which extends over the text in black but must always lie below the text. The text in black is contained within a span tag (but this could be a div as well if it needs to be).
My question is, is it possible to give black a z-index of, say, 1; red a z-index of 2; green a z-index of 3; and the text a z-index of 4?
This would make the above picture possible. However, browsers won't allow a child element to have a higher z-index than its parent so the above is not possible. The text always has an inherited z-index of 1, and therefore lies below green.
Is there a workaround?
P.S. I realise this can be a bit confusing to understand, hence the picture.
Link to comment
https://www.neowin.net/forum/topic/977136-can-you-create-a-child-element-with-a-higher-z-index-than-its-parent/Share on other sites
7 answers to this question
Recommended Posts