MÓDULO_TEÓRICO
Advanced Animations with @keyframes

Choreographing Motion on the Screen
While transition only interpolates between State A and State B (such as during a hover), Keyframe Animations (@keyframes) grant you full timeline mastery (0%, 25%, 50%, 100%) to orchestrate continuous loops, loaders, and complex entrance cinematics.
In this lesson, we will create elegant entrance effects (Fade in / Slide up), a pulsating live server status radar, and a sleek spinner.
1. The @keyframes Syntax
css/* 1. Define timeline keyframes */ @keyframes smoothEntrance { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } } /* 2. Apply animation to our Login card */ .login-card { animation: smoothEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
0.6s: Total duration.cubic-bezier: Snappy spring-like easing curve.forwards: Ensures the element retains its final 100% computed state.
2. Creating an Infinite Neon Radar Pulse (Status Dot)
See that green dot indicating live server status on the topbar? Let's build an infinite glowing sonar pulse:
css@keyframes radarPulse { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(0, 255, 136, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 136, 0); } } .status-dot { width: 10px; height: 10px; background-color: var(--success); border-radius: 50%; display: inline-block; animation: radarPulse 2s infinite; }
3. High-Speed Cyber Spinner
css@keyframes spin { to { transform: rotate(360deg); } } .radar-spinner { width: 32px; height: 32px; border: 3px solid rgba(0, 240, 255, 0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
⚡ Web Animation Performance: What to Animate
- ✅ ALWAYS ANIMATE:
transform(translate,scale,rotate) andopacity. These are GPU-composited at 60-120 FPS. - ❌ NEVER ANIMATE:
width,height,margin,top,left. They force CPU Reflow/Layout recalculations, inducing frame drops.
