CSS Animation Generator — Keyframe & Animation Builder
Generate CSS animations visually. Choose from 8 presets or customize timing, easing, and iteration count.
About CSS Animation Generator — Keyframe & Animation Builder
CSS Animation Generator creates @keyframes animations visually using a property editor. Animate opacity, transform (translateX, translateY, scale, rotate), background-color, border-radius, and more. Copy the ready-to-use CSS output.
How to Use
- 1Select a preset or enable individual CSS properties using the checkboxes in the property editor.
- 2Adjust FROM (0%) and TO (100%) values for each active property using sliders and color pickers.
- 3Set duration, timing function, iteration count, and fill mode, then copy the generated @keyframes CSS.
Features
- Animates 9 CSS properties: opacity, transform, color, border-radius, and more
- Live preview with replay button to see the animation in action
- Complex presets (bounce, shake, pulse, flip) with editable raw keyframes
- Generates complete @keyframes + animation shorthand CSS
CSS Animations: @keyframes and the animation Property
CSS animations allow you to smoothly transition element styles over time using the @keyframes rule combined with the animation shorthand property. Understanding both is essential for creating polished UI effects.
How @keyframes Works
The @keyframes rule defines animation frames by specifying CSS property values at percentage points along the animation timeline. The from keyword is equivalent to 0% (start state) and to is equivalent to 100% (end state). You can add intermediate frames: @keyframes slide { 0% { opacity: 0; transform: translateY(-20px); } 60% { opacity: 1; transform: translateY(5px); } 100% { transform: translateY(0); } }. Each percentage point is a keyframe where the browser interpolates property values between them. The browser automatically calculates the intermediate states using the specified timing function, creating smooth transitions between keyframes.
The animation Shorthand Properties
The animation shorthand value order is: name duration timing-function delay iteration-count direction fill-mode play-state. Example: animation: fadeIn 0.4s ease-out 0s 1 normal both running. The most important properties are: duration (how long one cycle takes), timing-function (easing curve — ease, linear, ease-in, ease-out, ease-in-out, cubic-bezier()), iteration-count (number of repetitions, or infinite), and fill-mode (what styles apply before and after the animation).
fill-mode: none vs forwards vs both
animation-fill-mode controls what styles apply outside the active animation period. none (default): the element reverts to its original CSS styles before and after the animation — the animated values only apply during the duration. forwards: after the animation ends, the element retains the styles from the final keyframe (100%). This is what makes elements "stay" in their animated state. backwards: before the animation starts (during delay), the from (0%) keyframe styles apply rather than the element's original styles. both: combines forwards and backwards — the most useful setting for entrance animations and one-time effects.
Animation Performance and Best Practices
CSS animations can be visually stunning or performance-crushing depending on which properties you animate. Following a few key principles ensures smooth 60fps animations.
Animating GPU-Accelerated Properties
Modern browsers can offload certain CSS animations to the GPU, running them on a separate compositor thread independent of JavaScript execution. The properties that trigger GPU acceleration are: transform (all functions: translate, scale, rotate, skew) and opacity. These two properties can animate at 60fps even when the main thread is busy. All other CSS properties — width, height, top, left, background-color, border-radius, box-shadow — cause layout recalculation or paint operations on the main thread, which is much more expensive. For performance-critical animations like loaders, transitions, and scroll effects, restrict your animations to transform and opacity whenever possible.
will-change and Hardware Acceleration Hints
The will-change property tells the browser in advance that an element will be animated, allowing it to optimize rendering by promoting the element to its own compositor layer. Example: will-change: transform, opacity. This creates a new stacking context and allocates GPU memory for the element before the animation starts, eliminating the visual jank sometimes seen on the first frame of complex animations. Use will-change sparingly — applying it to many elements simultaneously consumes significant GPU memory and can degrade performance. Apply it only to elements you are actively about to animate, and remove it after the animation completes if possible.
Reducing Motion for Accessibility
Some users experience motion sickness, dizziness, or cognitive overload from animations, particularly those involving large movements, rapid flashing, or parallax effects. The prefers-reduced-motion media query lets you disable or simplify animations for these users: @media (prefers-reduced-motion: reduce) { .animated-element { animation: none; transition: none; } }. Implementing this is a WCAG 2.1 AAA criterion and is considered good accessibility practice for any animation-heavy interface. Users can enable this preference in macOS (System Settings → Accessibility → Display → Reduce Motion) and Windows (Settings → Ease of Access → Display → Show animations).
FAQ
- Can I animate multiple properties at once?
- Yes. Enable any combination of properties (e.g., opacity + translateY + scale) and set FROM/TO values for each.
- What is animation-fill-mode?
- "both" applies the from-state before start and the to-state after end — the most common setting for one-time animations.
- Can I edit the raw @keyframes for complex animations?
- Yes. Selecting a complex preset (bounce, shake, pulse, flip, or custom) shows an editable textarea with the raw @keyframes code.
- How do I trigger a CSS animation when an element scrolls into view?
- Use the Intersection Observer API in JavaScript to add a class to the element when it enters the viewport, and apply the animation to that class. Example: the element starts with opacity: 0 and no animation; when the observer fires, add class="animate-in" which applies animation: fadeIn 0.5s forwards. Remove the class to allow re-animation on scroll. This approach keeps the animation in CSS while using JavaScript only for the trigger condition.
- What is animation-iteration-count: infinite and how do I pause it?
- animation-iteration-count: infinite makes the animation loop forever — used for loading spinners, pulsing effects, and continuous decorative animations. To pause an infinite animation: element.style.animationPlayState = 'paused' (JavaScript) or add a class with animation-play-state: paused (CSS). Respect prefers-reduced-motion: users with motion sensitivity should not have infinitely looping animations, as these can be disorienting. Use @media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }.
Found a bug or something not working as expected?
Report a bug →