I can't work out why this z-index isn't working on my page.
Here is a working example: https://jsfiddle.net/daeyqv31/
#login_modal_wrapper {
background: #eee;
background: red;/*rgba(0,0,0,0.7);*/
width: 100%; height: 100%;
position: fixed; top: 0; left: 0;
z-index: 10003;
}
#login_modal {
z-index: 10002;
background: #eee;
border: 2px solid #092834;
border: 2px solid rgba(9,40,52,0.6);
border-radius: 20px;
width: 700px;
height: 240px;
position: fixed;
top: 50%;
left: 50%;
margin-left: -350px;
margin-top: -120px;
}
#login_modal_wrapper.over {
z-index: 100003; // this needs to go OVER login_modal
}
#ajax_spinner {
width: 34px;
height: 34px;
position: fixed;
top: 50%;
left: 50%;
margin-left: -17px;
margin-top: -17px;
z-index: 200000;
}
However, I then also want to be able to force the #login_modal_wrapper
div to go OVER #login_modal
. So, I've got this (just a basic example);
https://jsfiddle.net/daeyqv31/1/
So this:
<div id="ajax_spinner">
loading icon
</div>
<div id="login_modal_wrapper">
<div id="login_modal"></div>
</div>
becomes:
<div id="ajax_spinner">
loading icon
</div>
<div id="login_modal_wrapper" class="over">
<div id="login_modal"></div>
</div>
...yet the z-index doesn't seem to be honored (it still shows #login_modal
on the top, when it should in fact be behind #login_modal_wrapper
UPDATE: As commented on below, there is no way to apply a higher z-index to a div that is a parent. To get around this, I just jiggled the HTML around a little:
<div id="ajax_spinner"><img src="/images/new/ajax-loader.gif" /></div>
<div id="login_modal"></div>
<div id="login_modal_wrapper"></div>
This now works exactly as expected :)