All tools

CSS animation generator

Create keyframe animations with a live preview.

Configuration

Animation

Result

CSS
@keyframes bounce {
  0%, 20%, 53%, 100% { transform: translateY(0); }
  40%, 43% { transform: translateY(-30px); }
  70% { transform: translateY(-15px); }
  90% { transform: translateY(-4px); }
}

.element {
  animation: bounce 1s ease 0s infinite normal both;
}

/* Respect people who ask their system for less motion. */
@media (prefers-reduced-motion: reduce) {
  .element { animation: none; }
}

About the CSS animation generator

CSS animations bring interfaces to life: content fading in, a notification sliding from the side, a loading spinner, or a button that pulses for attention. They need no JavaScript, just @keyframes and the animation property.

This generator starts from proven keyframe presets such as fade, slide, zoom, bounce, shake, swing and spin. Adjust the timing and repetition, watch the live preview, and copy the code, with an optional fallback for people who prefer less motion.

How to use the CSS animation generator

  1. Choose an animation, and optionally give it your own name.
  2. Set the duration, delay, timing function, how many times it repeats, its direction and fill mode.
  3. Use Play, Pause and Replay to check the preview.
  4. Click Copy CSS and add the .element class (or your own selector) to the element you want to animate.

Example

Slide in from the bottom, once

Input

Preset: Slide in from bottom · 0.4s · ease-out · 1 iteration · fill both

Output

@keyframes slide-in-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.element {
  animation: slide-in-up 0.4s ease-out 0s 1 normal both;
}

/* Respect people who ask their system for less motion. */
@media (prefers-reduced-motion: reduce) {
  .element { animation: none; }
}

The reduced-motion rule turns the animation off for people who ask their system for less motion.

Common errors and how to fix them

The animation runs but the element jumps back at the end

Without a fill mode, the element returns to its original styles. Add animation-fill-mode: forwards, or both to also apply the first frame during a delay.

The animation doesn't run at all

The name in animation must exactly match the @keyframes name, and a duration is required; 0s is the default.

The animation is janky

Animating width, top or margin forces layout on every frame. Animate transform and opacity, which the browser can run on the GPU.

Good to know

  • The animation shorthand is written in this order: name, duration, timing function, delay, repeat count, direction and fill mode.
  • Fill mode both keeps the first keyframe during the delay and the last keyframe after the end, so an entrance animation doesn't flash before it starts or jump back afterwards.
  • Animations that use only transform and opacity, like all the presets here, run smoothly on the GPU without causing layout work.
  • The reduced-motion fallback turns the animation off for people who have asked their device for less motion, for example because motion makes them dizzy. The site also respects that setting: the preview plays only when you press Play.
  • Swing sets transform-origin: top center so the element swings from the top, like a hanging sign.

Frequently asked questions

What's the difference between a CSS transition and an animation?

A transition animates between two states when a property changes, such as on hover. An animation uses @keyframes to run through any number of steps on its own, can repeat or loop, and can start as soon as the page loads.

How do I run an animation only when an element scrolls into view?

Add the animation class with JavaScript using an IntersectionObserver when the element becomes visible. In newer browsers you can also use scroll-driven animations with animation-timeline: view().

Which timing function should I use?

ease-out feels natural for things entering the screen, ease-in for things leaving, and ease-in-out for movement from one place to another. Use linear for constant motion such as a spinner.