← Back to Overview Chapter 04: Animation

1. Smooth Transitions & UI Interactions

CSS transitions interpolate between property values during state changes (e.g., :hover, :focus, :active, or class toggles).

Interactive Underline Slide →
Pure CSS checkbox transition
/* Smooth button lift */
.btn {
    transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}
.btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0,0,0,0.18);
}

2. Keyframe Animations with OpenMoji

@keyframes gives complete control over the intermediate steps of an animation sequence.

Rocket
Float (Hovering)
3s ease-in-out infinite
Loader
Spin (Loader)
2s linear infinite
Heart
Heartbeat Pulse
1.6s ease-in-out infinite
Fire
Form error feedback
@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(-5deg); }
    50%      { transform: translateY(-18px) rotate(5deg); }
}
.floating-element {
    animation: float 3s ease-in-out infinite;
}

3. Skeleton Loading Shimmer Effect

Modern apps (YouTube, Facebook, LinkedIn) display pulsating shimmer gradients instead of static spinners while content loads.

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

4. Animated Gradient Text & Infinite Marquee

Seamless loops that add energy and character to headers and announcements.

Pure CSS Animated Gradient
Infinite Ticker (Hover to Pause):
🚀 Rocket Speed 🎨 OpenMoji Visuals 💎 Pixel Perfection ✨ Modern CSS3 Magic 🚀 Rocket Speed 🎨 OpenMoji Visuals 💎 Pixel Perfection ✨ Modern CSS3 Magic
/* Infinite horizontal ticker */
@keyframes marquee {
    0%   { transform: translateX(0%); }
    100% { transform: translateX(-50%); }
}
.ticker {
    display: inline-flex;
    animation: marquee 12s linear infinite;
}
.ticker:hover {
    animation-play-state: paused; /* Pause on mouse hover! */
}

5. Modern Scroll-Driven & Discrete Animations (#25, #26, #28)

Scroll-driven Animation: Look at the very top edge of your browser window — the gradient reading progress bar responds directly to your page scroll via animation-timeline: scroll(root block) with zero JavaScript!

@starting-style + allow-discrete:
✨ Smooth entry from display: none!

Traditionally, transitioning from display: none to block was impossible without JS. Modern CSS solves this with @starting-style and allow-discrete!

pointer-events: none Click-Through:
Wand
Clicking directly on the magic wand icon still triggers the underlying select element because of pointer-events: none!
/* Scroll-driven progress bar */
.progress-bar {
    animation: grow auto linear;
    animation-timeline: scroll(root block); /* Native browser scroll timeline! */
}

/* Animate display: none using @starting-style */
.dialog {
    transition: opacity 0.4s ease, display 0.4s allow-discrete;
}
@starting-style {
    .dialog { opacity: 0; transform: translateY(-10px); }
}
Fixed 🏠