-
Animated background Login UI
HTML
CSS
JavaScript
Login
Username
Password
SIGN IN
Forgot Password?
Create New Account
Sign Up
Full Name
Email
Password
CREATE ACCOUNT
← Back to Login
* { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; display: flex; justify-content: center; align-items: center; overflow: hidden; font-family: Arial, sans-serif; background: radial-gradient(circle at 20% 20%, #46127a 0%, transparent 30%), radial-gradient(circle at 80% 80%, #b41470 0%, transparent 30%), linear-gradient(135deg, #10001f, #23003b, #10001f); } /* ========================= BACKGROUND ANIMATION ========================= */ .background { position: fixed; inset: 0; overflow: hidden; z-index: 0; } /* Large rotating triangle */ .bg-triangle { position: absolute; width: 650px; height: 650px; left: 50%; top: 50%; transform: translate(-50%, -50%); clip-path: polygon( 50% 0%, 100% 100%, 0% 100% ); background: linear-gradient( 45deg, #ff0080, #7928ca, #ff0080, #00e5ff ); background-size: 400% 400%; opacity: 0.25; filter: blur(2px); animation: backgroundTriangleRotate 18s linear infinite, backgroundGradient 8s ease infinite; } /* Second triangle */ .bg-triangle.two { width: 900px; height: 900px; opacity: 0.10; animation: backgroundTriangleReverse 25s linear infinite, backgroundGradient 12s ease infinite; } /* Triangle glow */ .bg-triangle::before { content: ""; position: absolute; inset: 15px; clip-path: polygon( 50% 0%, 100% 100%, 0% 100% ); background: #12001f; } /* Rotating background */ @keyframes backgroundTriangleRotate { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } } @keyframes backgroundTriangleReverse { 0% { transform: translate(-50%, -50%) rotate(360deg); } 100% { transform: translate(-50%, -50%) rotate(0deg); } } @keyframes backgroundGradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } /* ========================= FLOATING PARTICLES ========================= */ .particle { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #ff4da6; box-shadow: 0 0 10px #ff0080, 0 0 20px #ff0080; animation: floatParticle 8s linear infinite; } .p1 { left: 10%; bottom: -20px; animation-delay: 0s; } .p2 { left: 25%; bottom: -20px; animation-delay: 2s; } .p3 { left: 45%; bottom: -20px; animation-delay: 4s; } .p4 { left: 70%; bottom: -20px; animation-delay: 1s; } .p5 { left: 90%; bottom: -20px; animation-delay: 3s; } @keyframes floatParticle { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-110vh); opacity: 0; } } /* ========================= MAIN CONTAINER ========================= */ .container { position: relative; width: 420px; min-height: 520px; display: flex; justify-content: center; align-items: center; z-index: 10; } /* ========================= STATIC NEON TRIANGLE FRAME ========================= */ .triangle-frame { position: absolute; width: 410px; height: 410px; top: 40px; clip-path: polygon( 50% 0%, 100% 100%, 0% 100% ); background: linear-gradient( 135deg, #ff0080, #7928ca, #ff0080 ); filter: drop-shadow(0 0 8px #ff0080) drop-shadow(0 0 25px #8b2cff); animation: frameGlow 3s ease-in-out infinite; } .triangle-frame::before { content: ""; position: absolute; inset: 5px; clip-path: polygon( 50% 0%, 100% 100%, 0% 100% ); background: #180022; } @keyframes frameGlow { 0%, 100% { filter: drop-shadow(0 0 6px #ff0080) drop-shadow(0 0 15px #7928ca); } 50% { filter: drop-shadow(0 0 15px #ff0080) drop-shadow(0 0 35px #7928ca); } } /* ========================= LOGIN / SIGNUP CARD ========================= */ .flip-container { position: relative; width: 320px; height: 390px; perspective: 1000px; z-index: 20; } .flip-card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.8s ease; } .flip-card.flipped { transform: rotateY(180deg); } .form-card { position: absolute; width: 100%; height: 100%; padding: 38px 30px; border-radius: 20px; background: linear-gradient( 145deg, rgba(45, 0, 70, 0.95), rgba(18, 0, 32, 0.98) ); border: 1px solid rgba(255, 0, 128, 0.5); box-shadow: 10px 10px 30px rgba(0,0,0,0.6), -5px -5px 20px rgba(255,0,128,0.08), inset 0 0 20px rgba(255,0,128,0.08); backface-visibility: hidden; } .signup-card { transform: rotateY(180deg); } /* ========================= FORM ========================= */ h1 { text-align: center; margin-bottom: 28px; color: #fff; font-size: 30px; text-shadow: 0 0 10px #ff0080, 0 0 25px #7928ca; } .input-box { position: relative; margin-bottom: 22px; } .input-box input { width: 100%; padding: 14px 15px; border: none; outline: none; border-radius: 10px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,0,128,0.35); color: #fff; font-size: 14px; transition: 0.3s; } .input-box input:focus { border-color: #ff0080; box-shadow: 0 0 8px rgba(255,0,128,0.5), 0 0 20px rgba(121,40,202,0.3); } .input-box label { position: absolute; left: 15px; top: 14px; color: #aaa; pointer-events: none; transition: 0.3s; font-size: 14px; } .input-box input:focus + label, .input-box input:not(:placeholder-shown) + label { top: -9px; left: 12px; padding: 0 6px; background: #24003a; color: #ff4da6; font-size: 11px; } /* ========================= BUTTON ========================= */ button { width: 100%; padding: 14px; border: none; border-radius: 10px; cursor: pointer; color: #fff; font-weight: bold; font-size: 15px; background: linear-gradient( 90deg, #ff0080, #7928ca, #ff0080 ); background-size: 200% auto; box-shadow: 0 0 12px rgba(255,0,128,0.6); transition: 0.3s; } button:hover { background-position: right center; transform: translateY(-2px); box-shadow: 0 0 20px rgba(255,0,128,0.9), 0 0 40px rgba(121,40,202,0.5); } /* ========================= LINKS ========================= */ .links { text-align: center; margin-top: 20px; } .links a { color: #ff4da6; text-decoration: none; font-size: 13px; cursor: pointer; transition: 0.3s; } .links a:hover { color: #fff; text-shadow: 0 0 10px #ff0080; } /* ========================= MESSAGE ========================= */ .message { min-height: 22px; margin-top: 15px; text-align: center; font-size: 13px; font-weight: bold; opacity: 0; } .message.show { opacity: 1; } .message.success { color: #00ffae; text-shadow: 0 0 10px rgba(0,255,174,0.8); } .message.error { color: #ff3860; text-shadow: 0 0 10px rgba(255,0,70,0.8); } /* ========================= ERROR SHAKE ========================= */ .error-shake { animation: errorShake 0.45s ease; } @keyframes errorShake { 0% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(8px); } 100% { transform: translateX(0); } } /* ========================= ERROR INPUT ========================= */ .input-error { border-color: #ff1744 !important; box-shadow: 0 0 8px rgba(255,23,68,0.7), 0 0 20px rgba(255,23,68,0.35) !important; } /* ========================= RESPONSIVE ========================= */ @media(max-width:600px) { .container { transform: scale(0.85); } .bg-triangle { width: 500px; height: 500px; } } @media(max-width:420px) { .container { transform: scale(0.75); } }
const flipCard = document.getElementById("flipCard"); const loginForm = document.getElementById("loginForm"); const signupForm = document.getElementById("signupForm"); const showSignup = document.getElementById("showSignup"); const showLogin = document.getElementById("showLogin"); const loginMessage = document.getElementById("loginMessage"); const signupMessage = document.getElementById("signupMessage"); const username = document.getElementById("username"); const password = document.getElementById("password"); /* ========================= SHOW SIGNUP ========================= */ showSignup.addEventListener("click", function(e) { e.preventDefault(); flipCard.classList.add("flipped"); clearMessage(loginMessage); }); /* ========================= SHOW LOGIN ========================= */ showLogin.addEventListener("click", function(e) { e.preventDefault(); flipCard.classList.remove("flipped"); clearMessage(signupMessage); }); /* ========================= LOGIN ========================= */ loginForm.addEventListener("submit", function(e) { e.preventDefault(); clearMessage(loginMessage); username.classList.remove("input-error"); password.classList.remove("input-error"); const user = username.value.trim(); const pass = password.value.trim(); /* DEMO LOGIN Username: admin Password: 123456 */ if ( user === "admin" && pass === "123456" ) { loginMessage.textContent = "✓ Login successful!"; loginMessage.className = "message success show"; } else { /* Add red input effect */ username.classList.add("input-error"); password.classList.add("input-error"); /* Shake form */ const card = loginForm.closest(".form-card"); card.classList.remove("error-shake"); void card.offsetWidth; card.classList.add("error-shake"); /* Error message */ loginMessage.textContent = "✕ Invalid username or password"; loginMessage.className = "message error show"; } }); /* ========================= SIGNUP ========================= */ signupForm.addEventListener("submit", function(e) { e.preventDefault(); clearMessage(signupMessage); const name = document.getElementById("signupName").value.trim(); const email = document.getElementById("signupEmail").value.trim(); const pass = document.getElementById("signupPassword").value.trim(); if ( name === "" || email === "" || pass === "" ) { signupMessage.textContent = "✕ Please fill all fields"; signupMessage.className = "message error show"; return; } if (pass.length < 6) { signupMessage.textContent = "✕ Password must be at least 6 characters"; signupMessage.className = "message error show"; return; } signupMessage.textContent = "✓ Account created successfully!"; signupMessage.className = "message success show"; setTimeout(function() { flipCard.classList.remove("flipped"); username.value = email; password.value = ""; clearMessage(signupMessage); }, 1500); }); /* ========================= CLEAR MESSAGE ========================= */ function clearMessage(element) { element.textContent = ""; element.className = "message"; }
Live Preview