CSS Keyframes Generator
Design highly customized CSS keyframe animations visually. Add percentage steps, adjust translations, scales, rotations, skews, opacity, border-radius, and backgrounds. Preview your custom animation in real-time, and instantly export production-ready CSS.
Select, add, or delete percentage stages along the animation progress track.
Deep Dive into CSS Keyframe Animations
Understanding the CSS @keyframes Rule
The @keyframes rule is the core foundation behind custom CSS animations. It allows developers to specify styled changes at multiple steps along a timeline progress bar, mapped from 0% (the animation starting point, also represented by the keyword from) to 100% (the animation final state, or to).
Unlike simple transitions that only linearise properties between two basic states, keyframes let you design beautiful multi-step paths (like 0% to 25% to 50% and so on) with completely different translations, shapes, and color changes in a single combined timeline.
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
} Attaching Animation Classes
Once your keyframe declaration is built, you attach the animation to any HTML DOM element using a companion CSS selector class. The class links to the keyframe's customized name using the animation-name property, and adjusts performance using properties such as duration, timing function, loops, delay, and fill-mode.
.animated-card {
animation-name: spin;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
} Maximizing Animation Performance (Hardware Acceleration)
To ensure animations run at a buttery-smooth 60fps on both desktop and mobile viewports, it is highly recommended to animate only two CSS properties: transform (translate, scale, rotate, skew) and opacity.
Animating properties like top, left, width, or margin triggers browser reflows. Reflows force the browser to recalculate the entire page layout on every frame, leading to CPU bottlenecking and choppy, stuttering animations.
Using CSS transform maps calculations directly to the graphics card (GPU). The browser skips layout reflowing entirely, enabling hardware acceleration and preserving ultra-smooth, responsive user interactions.
@keyframes bounce-morph {
0%, 100% {
transform: translateY(0) scaleY(1);
border-radius: 8px;
}
50% {
transform: translateY(-50px) scaleY(0.9);
border-radius: 50%;
}
} Frequently Asked Questions
What is a CSS keyframe animation and how does it differ from a transition?
CSS keyframe animations (@keyframes) allow you to design complex, multi-stage animations by defining custom styles at various percentage points along a timeline. In contrast, CSS transitions only animate an element from an initial state to a final state, usually triggered by a state change like :hover or JavaScript class changes. Keyframe animations can run automatically, loop infinitely, and have highly complex visual paths.
Why should I animate using CSS transforms instead of top/left/width/height properties?
Animating layout-based properties like top, left, width, or height triggers the browser's layout and paint pipelines, which are computationally heavy and cause screen stuttering. Animating transform (like translate, scale, rotate, skew) and opacity runs on the GPU using hardware acceleration. This achieves ultra-smooth 60fps animations because the browser can skip layout calculations entirely.
What is the difference between animation-fill-mode options like forwards, backwards, and both?
animation-fill-mode defines what styles are applied to the element before the animation starts and after it finishes. "none" applies no styles before or after. "forwards" retains the styles defined in the last keyframe (100% or to) after the animation ends. "backwards" applies the styles from the first keyframe (0% or from) during the animation delay. "both" applies both rules, ensuring a seamless visual state throughout.
Do modern browsers require vendor prefixes (like -webkit-) for CSS @keyframes?
No, modern browsers have fully standardized the CSS Animation specification. Vendor prefixes like -webkit-keyframes, -moz-keyframes, or -o-keyframes are no longer necessary for standard production websites. This tool outputs clean, standardized, prefix-safe CSS code that works across all modern mobile and desktop browsers.