How to make a popup login page in html

Key Features:
Modern UI Design:

  • Clean, minimalist interface with rounded corners
  • Soft shadows and smooth animations
  • Segoe UI system font for modern typography

Popup Functionality:

  • Centered modal with scale-in animation
  • Semi-transparent overlay that dims the background
  • Close button (×) in top-right corner
  • Closes when clicking outside or pressing Escape

Form Elements:

  • Email/username field
  • Password field
  • "Remember me" checkbox
  • "Forgot password?" link
  • Submit button with hover animation

Interactive Effects:

  • Input field focus effects with soft glow
  • Button hover and active states
  • Smooth transitions for all interactive elements
  • Social login options (visual only)

Responsive Design:

  • Adapts to mobile screens
  • Proper spacing and sizing on all devices
  • Stacked layout for smaller screens

Accessibility:

  • Proper labels for all form fields
  • Keyboard navigation (Escape to close)
  • Focus states for interactive elements

The form includes all the requested features and provides a polished user experience with smooth animations and intuitive interactions. The JavaScript handles the modal opening/closing functionality while maintaining accessibility standards.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Popup Login Form</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> </head> <body> <button class="login-trigger">Login</button> <div class="overlay"> <div class="login-form"> <button class="close-btn">×</button> <div class="form-header"> <h2>Welcome Back</h2> <p>Please enter your details to sign in</p> </div> <form> <div class="form-group"> <label for="email">Email or Username</label> <input type="text" id="email" placeholder="Enter your email or username"> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" id="password" placeholder="Enter your password"> </div> <div class="form-footer"> <label class="remember-me"> <input type="checkbox"> Remember me </label> <a href="#" class="forgot-password">Forgot password?</a> </div> <button type="submit" class="submit-btn">Sign In</button> <div class="social-login"> <p>Or continue with</p> <div class="social-icons"> <div class="social-icon facebook"> <i class="fab fa-facebook-f"></i> </div> <div class="social-icon google"> <i class="fab fa-google"></i> </div> <div class="social-icon twitter"> <i class="fab fa-twitter"></i> </div> </div> </div> </form> </div> </div> </body> </html>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


/* Base Styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
        }

        body {
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #f5f7fa;
        }

        /* Trigger Button */
        .login-trigger {
            padding: 12px 24px;
            background: #4a6cf7;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(74, 108, 247, 0.2);
        }

        .login-trigger:hover {
            background: #3a5ce4;
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(74, 108, 247, 0.3);
        }

        .login-trigger:active {
            transform: translateY(0);
        }

        /* Overlay */
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(5px);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .overlay.active {
            display: flex;
            opacity: 1;
        }

        /* Login Form */
        .login-form {
            background: white;
            border-radius: 12px;
            width: 100%;
            max-width: 400px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            transform: scale(0.9);
            transition: all 0.3s ease;
            position: relative;
            opacity: 0;
        }

        .overlay.active .login-form {
            transform: scale(1);
            opacity: 1;
        }

        .close-btn {
            position: absolute;
            top: 15px;
            right: 15px;
            background: none;
            border: none;
            font-size: 1.5rem;
            color: #888;
            cursor: pointer;
            transition: color 0.2s ease;
        }

        .close-btn:hover {
            color: #333;
        }

        .form-header {
            text-align: center;
            margin-bottom: 25px;
        }

        .form-header h2 {
            color: #333;
            font-weight: 600;
            margin-bottom: 5px;
        }

        .form-header p {
            color: #777;
            font-size: 0.9rem;
        }

        .form-group {
            margin-bottom: 20px;
            position: relative;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .form-group input {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 0.95rem;
            transition: all 0.3s ease;
        }

        .form-group input:focus {
            outline: none;
            border-color: #4a6cf7;
            box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
        }

        .form-group input:hover {
            border-color: #bbb;
        }

        .form-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            font-size: 0.9rem;
        }

        .remember-me {
            display: flex;
            align-items: center;
            gap: 8px;
            color: #555;
        }

        .remember-me input {
            accent-color: #4a6cf7;
        }

        .forgot-password {
            color: #4a6cf7;
            text-decoration: none;
            transition: color 0.2s ease;
        }

        .forgot-password:hover {
            color: #3a5ce4;
            text-decoration: underline;
        }

        .submit-btn {
            width: 100%;
            padding: 12px;
            background: #4a6cf7;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .submit-btn:hover {
            background: #3a5ce4;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);
        }

        .submit-btn:active {
            transform: translateY(0);
        }

        .social-login {
            margin-top: 25px;
            text-align: center;
        }

        .social-login p {
            color: #777;
            font-size: 0.9rem;
            margin-bottom: 15px;
            position: relative;
        }

        .social-login p::before,
        .social-login p::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 30%;
            height: 1px;
            background: #eee;
        }

        .social-login p::before {
            left: 0;
        }

        .social-login p::after {
            right: 0;
        }

        .social-icons {
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .social-icon {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1.1rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .social-icon:hover {
            transform: translateY(-3px);
        }

        .facebook {
            background: #3b5998;
        }

        .google {
            background: #db4437;
        }

        .twitter {
            background: #1da1f2;
        }

        /* Responsive Design */
        @media (max-width: 480px) {
            .login-form {
                padding: 25px 20px;
                margin: 0 15px;
            }

            .form-header h2 {
                font-size: 1.3rem;
            }

            .form-footer {
                flex-direction: column;
                gap: 10px;
                align-items: flex-start;
            }
        }
JavaScript makes the page work functionally. At last, create a JavaScript file with the name of script.js, and remember that you've got to make a file with a .js extension.


 document.addEventListener('DOMContentLoaded', function() {
            const loginTrigger = document.querySelector('.login-trigger');
            const overlay = document.querySelector('.overlay');
            const closeBtn = document.querySelector('.close-btn');
            const loginForm = document.querySelector('.login-form');

            // Open modal
            loginTrigger.addEventListener('click', function() {
                overlay.classList.add('active');
                document.body.style.overflow = 'hidden'; // Prevent scrolling
            });

            // Close modal
            function closeModal() {
                overlay.classList.remove('active');
                document.body.style.overflow = ''; // Re-enable scrolling
            }

            closeBtn.addEventListener('click', closeModal);
            overlay.addEventListener('click', function(e) {
                if (e.target === overlay) {
                    closeModal();
                }
            });

            // Close with Escape key
            document.addEventListener('keydown', function(e) {
                if (e.key === 'Escape' && overlay.classList.contains('active')) {
                    closeModal();
                }
            });

            // Form submission
            const form = document.querySelector('form');
            form.addEventListener('submit', function(e) {
                e.preventDefault();
                // Add your form submission logic here
                alert('Login functionality would be implemented here');
                closeModal();
            });
        });

We hope you would like this Calculator using html css and javascript code

Thank you
Learning robo team

إرسال تعليق

Thank you
Learning robo team

Post a Comment (0)

أحدث أقدم
Learning Robo says...
code copied
Welcome