Animated login page in HTML can be achieved using a combination of HTML, CSS, and a bit of JavaScript for enhanced interactivity

Creating an animated login page in HTML can be achieved using a combination of HTML, CSS, and a bit of JavaScript for enhanced interactivity. Below is an example of a simple animated login page.



HTML


<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Animated Login Page</title> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="login-container"> <div class="login-box"> <h2>Login</h2> <form> <div class="input-group"> <input type="text" required> <label>Username</label> </div> <div class="input-group"> <input type="password" required> <label>Password</label> </div> <button type="submit">Login</button> </form> </div> </div> </body> </html>

------------------------------------

CSS (style.css)


body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: linear-gradient(120deg, #2980b9, #8e44ad); font-family: Arial, sans-serif; } .login-container { display: flex; justify-content: center; align-items: center; height: 100%; width: 100%; } .login-box { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); text-align: center; animation: fadeIn 1s ease-in-out; } .login-box h2 { margin: 0 0 20px; padding: 0; color: #333; } .input-group { position: relative; margin-bottom: 30px; } .input-group input { width: 100%; padding: 10px 10px 10px 5px; background: none; border: none; border-bottom: 1px solid #999; outline: none; color: #333; font-size: 16px; transition: 0.2s; } .input-group label { position: absolute; top: 10px; left: 5px; color: #999; font-size: 16px; pointer-events: none; transition: 0.2s; } .input-group input:focus ~ label, .input-group input:valid ~ label { top: -20px; left: 0; color: #8e44ad; font-size: 12px; } .input-group input:focus, .input-group input:valid { border-color: #8e44ad; border-bottom-width: 2px; } button { padding: 10px 20px; background: #8e44ad; border: none; color: white; border-radius: 5px; cursor: pointer; transition: background 0.3s; } button:hover { background: #732d91; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-50px); } to { opacity: 1; transform: translateY(0); } }

--------------------------------------------

Explanation

  1. HTML:

    • Defines the structure of the login page with a form that includes input fields for the username and password.
    • The label elements are positioned over the input fields and move up when the input is focused or contains a value.
  2. CSS:

    • Styles the body to center the login box and applies a gradient background.
    • Adds styles for the login box, including padding, border-radius, and a box-shadow for a card-like effect.
    • Animates the login box on page load with a fade-in effect.
    • Styles the input fields and labels to create a floating label effect.
    • Styles the submit button with a hover effect for visual feedback.

This example creates a visually appealing and interactive login form with simple animations. You can further customize it by adding more styles or JavaScript for additional functionality.




Post a Comment

0 Comments