DEV Community

Discussion on: Creating a CSS modal window (pop-up) step-by-step

Collapse
 
brendan8c profile image
Artem • Edited

Close the current window by clicking on the gray area.
The gray area is the non-shaped area.
I used JavaScript
.#modal - This is a gray blackout area.

let writeForm = document.getElementById("write");
document.onclick = function(e) {
    console.clear();
    if (e.target != writeForm && !writeForm.contains(e.target)) {
        window.location.replace("#");
    };
    console.info(e.target !== writeForm, !writeForm.contains(e.target));
};
Enter fullscreen mode Exit fullscreen mode

How to do this in pure "css" I don't have idea..