4 ms·
The elements in the "top layer" are stacked in the order they are "promoted" - for dialog elements this is when showModal() is called. So the element on which s
by goto11 4y ago
The elements in the "top layer" are stacked in the order they are "promoted" - for dialog elements this is when showModal() is called. So the element on which showModal() was most recently called is on top. If you want another dialog on top, call showModal on that.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogE...
- nailer 4y agoThanks, though that wasn't quite my question - do you still stack elements within a top layer using z-index?
- deleted 4y ago[deleted]
- goto11 4y agoElements promoted to the top layer stack according to the order they are promoted. Inside a promoted element, child elements are stacked according to the regular layout rules, i.e. same as if the element wasn't promoted. Think of the "top layer" as similar to inserting an element as the last child of the document body. This is how modals and overlays are usually implemented - by inserting the element last (and position it absolutely) it will automatically stack higher than anything else in the document. At least until something else is inserted last. Z-index is actually not that useful for stacking elements (whether in top layer or not) since it only works inside the scope of a stacking context. Element order is a better way to control stacking.