html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modern Login</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(45deg, #8e44ad, #3498db);
padding: 20px;
}
.login-container {
background: rgba(255, 255, 255, 0.95);
padding: 40px;
border-radius: 20px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
width: 100%;
max-width: 420px;
transition: transform 0.3s ease;
}
.login-container:hover {
transform: translateY(-5px);
}
h2 {
text-align: center;
color: #2c3e50;
margin-bottom: 35px;
font-size: 2.5em;
position: relative;
}
h2::after {
content: '';
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 4px;
background: linear-gradient(90deg, #8e44ad, #3498db);
border-radius: 2px;
}
.input-group {
margin-bottom: 25px;
position: relative;
}
input {
width: 100%;
padding: 15px;
border: 2px solid #eee;
border-radius: 10px;
font-size: 16px;
transition: all 0.3s ease;
}
input:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
}
label {
position: absolute;
left: 15px;
top: 50%;
transform: translateY(-50%);
color: #7f8c8d;
pointer-events: none;
transition: all 0.3s ease;
}
input:focus ~ label,
input:valid ~ label {
top: -10px;
left: 5px;
font-size: 12px;
color: #3498db;
background: white;
padding: 0 5px;
}
button {
width: 100%;
padding: 15px;
background: linear-gradient(90deg, #8e44ad, #3498db);
border: none;
border-radius: 10px;
color: white;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
button:hover {
background: linear-gradient(90deg, #9b59b6, #2980b9);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
button:active {
transform: scale(0.98);
}
.loading {
position: relative;
pointer-events: none;
}
.loading::after {
content: '';
position: absolute;
width: 30px;
height: 30px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: translate(-50%, -50%) rotate(360deg); }
}
.form-footer {
text-align: center;
margin-top: 25px;
color: #7f8c8d;
}
a {
color: #3498db;
text-decoration: none;
font-weight: 500;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Welcome Back</h2>
<form id="loginForm">
<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" id="loginBtn">Sign In</button>
</form>
<div class="form-footer">
<p>Don't have an account? <a href="#">Sign Up</a></p>
</div>
</div>
<script>
const loginBtn = document.getElementById('loginBtn');
loginBtn.addEventListener('click', function(e) {
e.preventDefault();
// Add loading animation
loginBtn.classList.add('loading');
// Simulate API call
setTimeout(() => {
loginBtn.classList.remove('loading');
alert('Login successful!');
}, 2000);
});
</script>
</body>
</html>
Để sử dụng chỉ cần copy toàn bộ code vào file .html và mở trong trình duyệt. Animation sẽ tự động chạy khi tương tác với form.