CSS Animation Generator
Build @keyframes animations visually. Set timing, duration, and keyframe properties with a live preview.
Keyframes
How to Use the CSS Animation Generator
- Choose a mode — Basic for transform/opacity animations, Multi-Property for color and background changes, or Presets for instant animations.
- Set the timing — Adjust duration, delay, easing function, iteration count, and direction using the controls.
- Edit keyframes — Each keyframe row represents a moment in the animation timeline. Set properties for 0%, 50%, 100%, or any custom percentage.
- Watch the preview — The preview box animates live. Use Play, Pause, and Restart to control it.
- Copy the CSS — Click Copy to grab the @keyframes rule and animation shorthand, ready to paste.
Understanding CSS Keyframe Animations
CSS animations let you define smooth transitions between multiple visual states over time. Unlike transitions that animate between two states on user interaction, animations play automatically and can loop indefinitely. They are defined using the @keyframes rule and controlled with the animation shorthand property.
The animation Shorthand
The full animation shorthand is: animation: name duration timing-function delay iteration-count direction fill-mode;. For example: animation: bounce 1s ease-in-out 0s infinite alternate both; This applies a pre-defined @keyframes bounce animation with the specified timing settings.
Timing Functions Explained
- ease — Starts quickly, decelerates. The most natural motion. Default value.
- linear — Constant speed. Good for spinning loaders and progress indicators.
- ease-in — Slow start, then accelerates. Good for exiting animations.
- ease-out — Fast start, decelerates. Good for entering animations.
- ease-in-out — Slow start and end, fast middle. Smooth and natural.
- cubic-bezier() — Full control over the speed curve with 4 values.
- steps() — Discrete jumps. Use for sprite sheet animation and typewriter effects.
Animation Direction and Iteration
Setting animation-direction: alternate makes the animation play forward, then backward. Combined with animation-iteration-count: infinite, this creates seamless ping-pong loops without abrupt jumps. For a single play-through that retains the final state, use animation-iteration-count: 1 and animation-fill-mode: forwards.
Performance: Which Properties to Animate
Always prefer animating transform and opacity. These are the only properties that browsers can animate on the GPU compositor thread without triggering layout or paint. Animating width, height, color, or background-color triggers paint operations and can cause frame drops on complex pages. For best performance, combine CSS animations with will-change: transform, opacity on elements you know will animate frequently. Explore more with the CSS Transform Playground or the CSS Filter Playground.
Accessible Animations
Always wrap looping or decorative animations in a prefers-reduced-motion media query: @media (prefers-reduced-motion: reduce) { .element { animation: none; } }. Users with vestibular disorders, epilepsy, or motion sensitivity benefit greatly from this. The WCAG 2.1 success criterion 2.3.3 recommends providing a way to pause, stop, or hide any moving content that lasts more than five seconds.
Frequently Asked Questions
animation: my-anim 2s ease-in-out infinite alternate;