Dialog without dialog Dialog content Container that hides everything else
HTML < div id = "my-dialog-container" > < div id = "my-dialog" > < p > Hello dialog </ p > < button type = "button" > Close </ button > </ div > </ div > < button id = "open-dialog" > Open dialog </ button >
CSS #my-dialog { display : none ; position : fixed ; padding : 1rem ; top : 50% ; left : 50% ; background-color : white ; border-style : dashed ; &[open] { display : block ; } } :has ( #my-dialog [ open ]) { background-color : black ; position : fixed ; top : ; right : ; width : 100% ; height : 300vh ; z-index : 1000 ; overflow-y : hidden ; }
Let’s wrap We have seen the new dialog element, got familiar with its properties and methods. UI-wize there is no big difference between dialog and a div with some CSS games, but we have some functionality of method and events that supports us as programmers
My code repo https://github.com/ranwahle/dialog-demo