0

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.

http://jsfiddle.net/dmcgrew/6cY84/

Dustin
  • 4,314
  • 12
  • 53
  • 91
  • 2
    For 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 Answers1

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