HTML / Markup
Public
Modern Animated Login Form
An animated login form with email and password fields, glowing Sign In button, and smooth hover effects.
HTML / Markup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Animated Login Form</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
*, *::before, *::after {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #667eea, #764ba2);
color: #eee;
}
.login-container {
background: #1e1e2f;
padding: 40px 50px;
border-radius: 12px;
box-shadow: 0 0 15px rgba(118, 75, 162, 0.7);
width: 320px;
display: flex;
flex-direction: column;
gap: 30px;
position: relative;
}
.login-container h2 {
text-align: center;
margin-bottom: 10px;
font-weight: 700;
letter-spacing: 2px;
color: #ddd;
}
.input-group {
width: 100%;
}
.input-group input {
width: 100%;
padding: 14px 18px;
border-radius: 8px;
border: 2px solid #444;
background: #2a2a3d;
color: #eee;
font-size: 16px;
outline-offset: 2px;
outline-color: transparent;
transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, outline-color 0.3s ease;
}
.input-group input::placeholder {
color: #bbb;
}
.input-group input:focus {
border-color: #a77eea;
box-shadow: 0 0 8px #a77eea;
background: #3b3b5c;
outline-color: #a77eea;
}
.sign-in-btn {
padding: 16px 0;
border: none;
border-radius: 10px;
background: linear-gradient(270deg, #764ba2, #667eea, #764ba2);
background-size: 600% 600%;
color: #fff;
font-weight: 700;
font-size: 18px;
cursor: pointer;
box-shadow: 0 0 20px #764ba2;
transition: box-shadow 0.3s ease, background-size 0.3s ease;
user-select: none;
animation: glowing 15s linear infinite;
}
.sign-in-btn:hover,
.sign-in-btn:focus {
box-shadow: 0 0 30px 4px #a77eea;
animation-play-state: paused;
background-size: 100% 100%;
outline: none;
}
@keyframes glowing {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
.error-message {
color: #ff6b6b;
font-size: 14px;
text-align: center;
height: 18px;
min-height: 18px;
}
</style>
</head>
<body>
<form class="login-container" id="loginForm" novalidate>
<h2>Sign In</h2>
<div class="input-group">
<input type="email" id="email" placeholder="Email" required />
</div>
<div class="input-group">
<input type="password" id="password" placeholder="Password" required minlength="6" />
</div>
<button type="submit" class="sign-in-btn">Sign In</button>
<div class="error-message" id="errorMsg" role="alert" aria-live="polite"></div>
</form>
<script>
const form = document.getElementById('loginForm');
const emailInput = document.getElementById('email');
const passwordInput = document.getElementById('password');
const errorMsg = document.getElementById('errorMsg');
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
form.addEventListener('submit', event => {
event.preventDefault();
errorMsg.textContent = '';
const email = emailInput.value.trim();
const password = passwordInput.value;
if (!email || !password) {
errorMsg.textContent = 'Please fill in all fields.';
return;
}
if (!emailPattern.test(email)) {
errorMsg.textContent = 'Please enter a valid email address.';
return;
}
if (password.length < 6) {
errorMsg.textContent = 'Password must be at least 6 characters.';
return;
}
alert('Login successful!');
form.reset();
});
</script>
</body>
</html>