How to create a dialog or popup using CSS?

A dialog is a small window that does not fill the screen and prompts the user to take any action before they can proceed.

By using CSS we can show a dialog to the user. We usually use JavaScript to show a dialog to the user. The CSS-based dialog is lightweight and less error-prone.

The following is a conde snippet for showing a dialog using pure CSS.

The HTML code:

<div id="popup-container" class="overlay">
    <div class="popup">
        <a class="close" href="#popup-container">&times;</a>
        <div class="content">
            Thank to pop me out of that button, but now i'm done so you can close this window.
        </div>
    </div>
</div>

The CSS:

    .overlay {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.7);
        transition: opacity 500ms;
        visibility: hidden;
        opacity: 0;
    }
    .overlay:not(:target) {
        visibility: visible;
        opacity: 1;
    }

    .popup {
        margin: 70px auto;
        padding: 20px;
        background: #fff;
        border-radius: 5px;
        width: 30%;
        position: relative;
        transition: all 5s ease-in-out;
    }

    .popup .close {
        position: absolute;
        top: 5px;
        right: 10px;
        transition: all 200ms;
        font-size: 20px;
        font-weight: bold;
        text-decoration: none;
        color: #333;
    }
    .popup .close:hover {
        color: #06D85F;
    }
    .popup .content {
        max-height: 30%;
        overflow: auto;
    }

    @media screen and (max-width: 700px){
        .popup{
            width: 70%;
        }
    }