const openM = document.getElementById("modal-btn"); const openD = document.getElementById("dialog-btn"); const modal = document.getElementById("modal"); const dialog = document.getElementById("dialog"); openM.onclick = e => modal.showModal(); openD.onclick = e => dialog.show(); const closeM = document.querySelector("#modal .close"); const closeD = document.querySelector("#dialog .close"); closeM.onclick = e => modal.close(); closeD.onclick = e => dialog.close(); const modal2 = document.getElementById("modal2"); document.getElementById("modal-btn2").onclick = e => modal2.showModal(); document.querySelector("#modal2 .close").onclick = e => modal2.close();
*, *::before, *::after { box-sizing: border-box; } :root { font: 2ch/1.5 "Segoe UI" } dialog { width: 70vw; max-width: 600px; border: 0; border-radius: 8px; box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; } dialog header { display: flex; justify-content: space-between; align-items: center; } h3 { margin: 0 } menu { display: flex; justify-content: center; gap: 0.25rem; list-style: none; padding: 0 } button, input { font: inherit; cursor: pointer; box-shadow: rgba(6, 24, 44, 0.4) 0px 0px 0px 2px, rgba(6, 24, 44, 0.65) 0px 4px 6px -1px, rgba(255, 255, 255, 0.08) 0px 1px 0px inset; } dialog button { width: 2rem; padding-inline: 0.25rem; } .close { width: 1.5rem; height: 1.5rem; padding-inline: 0.25rem; } #modal::backdrop { background: rgba(0, 0, 0, 0.3); } #modal2::backdrop { --s: 5rem; --c1: #3eb3d0; --c2: #7d3636; --G: var(--c2) 6% 14%, var(--c1) 16% 24%, var(--c2) 26% 34%, var(--c1) 36% 44%, var(--c2) 46% 54%, var(--c1) 56% 64%, var(--c2) 66% 74%, var(--c1) 76% 84%, var(--c2) 86% 94%; background: radial-gradient(100% 100% at 100% 0, var(--c1) 4%, var(--G), #0008 96%, #0000), radial-gradient(100% 100% at 0 100%, #0000, #0008 4%, var(--G), var(--c1) 96%) var(--c1); background-size: var(--s) var(--s); }
<header> <nav> <button id="modal-btn">Open Modal</button> <button id="dialog-btn">Open Dialog</button> <button id="modal-btn2">Open Modal</button> </nav> <dialog id="dialog"> <header> <h3>Dialog</h3> <input class="close" type="button" value="🞬"> </header> <menu> <li><button>VI</button></li> <li><button>VII</button></li> <li><button>VIII</button></li> <li><button>IX</button></li> <li><button>X</button></li> </menu> </dialog> </header> <main> <p>The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. </p> </main> <footer> Some footer stuff </footer> <dialog id="modal"> <header> <h3>Modal</h3> <input class="close" type="button" value="🞬"> </header> <menu> <li><button>I</button></li> <li><button>II</button></li> <li><button>III</button></li> <li><button>IV</button></li> <li><button>V</button></li> </menu> </dialog> <dialog id="modal2"> <header> <h3>Modal</h3> <input class="close" type="button" value="🞬"> </header> <menu> <li><button>XI</button></li> <li><button>XII</button></li> <li><button>XIII</button></li> <li><button>XIV</button></li> <li><button>XV</button></li> </menu> </dialog>
[popover]::backdropwill work for you, and other browser in which it doesn't.background: linear-gradient(transparent, transparent var(--header-height), var(--backdrop) var(--header-height), var(--backdrop));. It does the trick in this case.