css - Z-index in front of an element in a fixed position -
i not find solution problem turn :).
here context: have 2 brothers elements, 1 absolute position , other in fixed position. basic fixed element @ top. consider in code below:
* { box-sizing: border-box; } html, body{ margin: 0; padding: 0; height: 100%; width: 100%; } #element1 { background: red; height: 100%; width: 100%; position: absolute; } #element2 { background: green; margin: 0 auto; height: 200px; position: absolute; width: 600px; } #element3 { background: blue; height: 200px; position: fixed; bottom: 0; width: 100%; } #element1, #element3 { z-index: 1; } #element2 { z-index: 10; }
<div id="element1"> <div> <div id="element2"></div> </div> </div> <div id="element3"> </div>
http://jsfiddle.net/p7c9q/1162/
that green color area modal. objective make element green on element in fixed position.
how can unlock myself knowing element 1 , element 2 must remain in absolute position?
thank in advance, cordially.
element3
on element1
, children if child of element1
has higher z-index
because related parent element1
has lower z-index
element3
there 2 solutions case:
- put
element2
,element3
childrenelement1
* { box-sizing: border-box; } html, body{ margin: 0; padding: 0; height: 100%; width: 100%; } #element1 { background: red; height: 100%; width: 100%; position: absolute; } #element2 { background: green; margin: 0 auto; height: 200px; position: absolute; width: 600px; } #element3 { background: blue; height: 200px; position: fixed; bottom: 0; width: 100%; } #element1, #element3 { z-index: 1; } #element2 { z-index: 10; }
<div id="element1"> <div> <div id="element2"></div> </div> <div id="element3"> </div> </div>
- make
element2
outsideelement1
in same levelelement3
* { box-sizing: border-box; } html, body{ margin: 0; padding: 0; height: 100%; width: 100%; } #element1 { background: red; height: 100%; width: 100%; position: absolute; } #element2 { background: green; top:25%; left:15%; margin: 0 auto; height: 200px; position: fixed; width: 600px; } #element3 { background: blue; height: 200px; position: fixed; bottom: 0; width: 100%; }
<div id="element1"></div> <div id="element2"></div> <div id="element3"></div>
Comments
Post a Comment