I have two layers, one is black overlay:
#overlay { background: rgba(0,0,0,0.7); width: 100%; height: 100%; position: fixed; left: 0; top: 0; z-index: 0; display: none; }
the other is a text container:
#wrap { z-index: 999 width:600px; height:600px; border:5px solid black; display:none; color:red; }
I want the overlay and container to display at the same time:
$(document).click(function () { $('#overlay').add('#wrap').fadeIn(); })
but the text container is always under the overlay, although I imposed the z-index overlay on 0 and set the z-index container to 999.
Demo here
Finally, I found that I had to set the z-index overlay to -1 , it would work.
Why can't I set the z-index overlay above because its position is fixed?
source share