I have a dropdown control which is implemented a dialog (seems a div would behave the same), any way to place it over a modal dialog so it would behave as a dropdown and be independent of the modal? Tried several things with z-index
, no luck:
modal.showModal();
.dialog,
.popup {
z-index: 100000;
position: absolute;
}
#modal {
z-index: 1000;
top: 90px;
}
.popup {
top: 70px;
background: #faa;
border: 1px solid gray;
}
dialog,
.popup {
width: 400px;
height: 300px;
}
<dialog open class="dialog">Dialog</dialog>
<div class="popup">Popup</div>
<dialog id="modal">Modal
<dialog open class="dialog">Dialog</dialog>
<div class="popup">Popup</div>
</dialog>
3
Answers
Thanks for the answers, I've just decided to open the modal full page size and use it as a top layer window where I show the actual dialog like container and every other dropdowns added to it (not to the body) will behave as i need
There is no problem about open a modal hover an open one…
There’s two ways to open a
<dialog>
:With the
.showModal()
method the<dialog>
behaves as a modal. A modal will block the rest of the page from user interaction so a dropdown would definitely be inaccessible while a modal is open.Or with the
.show()
method which makes it behave as a dialog. A dialog does not interfere with user interaction with the page so a dropdown is definitely accessible while a dialog is open.If you want the
<dialog>
to be open when the page loads, use the methods instead of the[open]
attribute because you’ll have more control and more options. In the example below, there two<button>
s that open a<dialog>
both ways. There’s also a dropdown to test both modes with. Details are commented in the example.