Login Form Modal

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Form Modal</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet"> 
    <style>
        * {
            padding: 0;
            margin: 0;
            outline: 0;
            font-family: 'Montserrat', sans-serif;
        }

        body {
            background-color: #383838;
        }

        section#overlay {
            position: fixed;
            top: -100%;
            left: 0;
            right: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-image: linear-gradient(-45deg, #d400ff, #610ffa);
            visibility: hidden;
            opacity: 0;
            transition: 0.2s all linear;
        }

        section#overlay.active {
            visibility: visible;
            opacity: 1;
            top: 0;
        }

        section#overlay aside {
            background-color: #fff;
            width: 350px;
            padding: 20px;
            border-radius: 16px;
            position: relative;
        }

        section#overlay aside h2 {
            text-align: center;
            margin-bottom: 20px;
            font-size: 24px;
            color: #181818;
        }

        section#overlay aside a.close {
            position: absolute;
            top: 8px;
            right: 8px;
            cursor: pointer;
        }

        section#overlay aside a.close svg {
            width: 25px;
            height: 25px;
        }

        section#overlay aside h4 {
            font-size: 16px;
            color: #282828;
            margin-bottom: 8px;
        }

        input[type=text],
        input[type=password] {
            width: calc(100% - 20px);
            padding: 8px 10px;
            border: #cdcdcd solid 1px;
            border-radius: 5px;
            margin-bottom: 15px;
        }

        button[type=submit] {
            border: none;
            padding: 8px 20px;
            color: #fff;
            border-radius: 5px;
            font-size: 16px;
            background-image: linear-gradient(45deg, #d400ff, #610ffa);
        }

        

        div.btnSec {
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        button[type=button]{
            padding: 10px 20px;
            background-image: linear-gradient(60deg, #d400ff, #610ffa);
            color: #fff;
            border: none;
            font-size: 16px;
            border-radius: 10px;
        }
    </style>
    <script>
        function toggleModal() {
            document.getElementById("overlay").classList.toggle('active');
        }
    </script>
</head>
<body>
    <div class="btnSec">
        <button type="button" onclick="toggleModal()">Login Now!</button>
    </div>
    <section id="overlay">
        <aside>
            <h2>Login</h2>
            <form action="">
                <a onclick="toggleModal()" class="close">
                    <svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;stroke:#a70eff;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}</style></defs><title/><g id="cross"><line class="cls-1" x1="7" x2="25" y1="7" y2="25"/><line class="cls-1" x1="7" x2="25" y1="25" y2="7"/></g></svg> 
                </a>
                <h4>Username</h4>
                <input type="text" />
                <h4>Password</h4>
                <input type="password" />
                <button type="submit">Login</button>
            </form>
        </aside>
    </section>
</body>
</html>
                                Copy Code
                            

Result Screenshot(s)

Login Form ModalWorking Sample0