In my jquery modal dialog box, I wanted to create a shadow effect only between the dialog box and the screen. To achieve this, I added an overlay using a <div>
:
<div id="overlay" class="overlay btn-hidden"></div>
<div id="myDialogBox" name="myDialogBox" class="myDialogBox"></div>
I then styled it in CSS like so:
.myDialogBox {
z-index: 999 !important;
}
.overlay {
z-index: 800 !important;
position: fixed !important;
}
Everything seemed to work fine on desktop, with the overlay positioned right behind the dialog box. However, when testing on Chrome by switching from desktop to mobile view, I noticed that the overlay was appearing on top of the dialog box, making it difficult to interact with. I attempted setting position: relative
for the overlay within a
@media screen and (max-width: 769px)
query for mobile screens, but the overlay didn't even show up. Is there a solution to ensure the overlay stays behind the modal dialog box on both desktop and mobile screens?