I am trying to better understand the CSS
z-index
property and stacking contexts.
As practice, I've built a little HTML
demo containing some elements, and I am trying to order them in all kinds of different orders using z-index
positioning only.
The basic demo is available in this fiddle.
Now, is it possible to stack the elements in the above demo in the following order (farthest to closest): #d1, #d4, #d2, #d3
?
(To clarify, the order in the initial demo is: #d1, #d3, #d2, #d4
)
Edit:
Prior to asking this question, I have actually searched and read about z-index
and stacking contexts. I am familiar with the general rules and specification of how z-index
works, and when stacking contexts are created.
Hence, this is not a general "I do not understand how z-index works" question, and therefore it is not a duplicate of this question.
This question refers to the specific case that I have presented above in as much detail as I could. What I ask for is a very specific answer to that specific question - either "Yes, this can be done like so...", or "No, this can't be achieved, because..."