Why doesn't the red element go behind the blue one? This isn't making much sense to me. I've tried making the red element z-index: -1
but that does not work.
Asked
Active
Viewed 120 times
0

Dustin
- 4,314
- 12
- 53
- 91
-
2For your "Why" question, read my answer here: http://stackoverflow.com/questions/16504832/in-css-2-1-if-a-parent-establish-a-stacking-context-why-can-the-childrens-tex/16505305#16505305 – Arbel Dec 03 '13 at 17:55
1 Answers
1
The red element is a child of the blue one, so it will always be in front. If you make this slight change your styles will work:
<div class="parent"></div>
<div class="child">child</div>
Now those two div's are "on the same level" and the red one's z-index becomes meaningful, which in your code it wasn't.

John Smith
- 1,724
- 1
- 9
- 7