Z-index for children is higher than parent div

I have a parent div that has a fixed position. What I'm trying to do is get the child div1 to stand out when I blur the page, but the whole parent div stands out. After you read a lot of posts saying that the parent div overrides the z-index and the child z-index does not make sense, I got stuck here not knowing how to make this work.

If this does not help, can someone help me with a solution for this?

enter image description here

+4
source share
2 answers

, , , DOM. :

http://jsfiddle.net/4KLRU/1/

HTML:

<div id="container">
    <div class="child">Something</div>
    <div class="child behind_parent">Something else</div>
    <div class="child">Something else entirely</div>
    <div id="parent"></div>
</div>

, .

CSS

#container {
    position: fixed;
    padding: 10px;
}

#parent {
    background: orange;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
}

.child {
    position: relative;
    background: red;
    margin: 5px;
    z-index: 2;
}

.behind_parent {
    z-index: 0;   
}
+3

, , :

#parent {
  position: fixed;
  ...
}

#child {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  ...
}
0

All Articles