CSS
CSS Animations & Transitions Cheat Sheet
Everything needed to animate with CSS alone: transitions for state changes, keyframes for multi-step motion, and the transforms that keep it smooth.
Put it into practice with the matching tool.
Build a keyframe animation →Advertisement
Transitions
transition: opacity 200ms ease-outAnimate one property when it changestransition: transform 300ms, opacity 300msSeveral properties, each with its own timingtransition-delay: 100msWait before startingtransition-property: allAnimate every animatable property (can be costly)transition-behavior: allow-discreteAllow transitions on discrete properties such as display@starting-style { ... }Starting values for an element's entry transitionKeyframes
@keyframes spin { to { rotate: 360deg; } }Define a named animationfrom { } to { }Same as 0% and 100%0%, 100% { } 50% { }Share one keyframe between several pointsAnimation properties
animation: spin 1s linear infiniteShorthand: name, duration, timing, iterationsanimation-delay: 200msWait before starting (negative starts part-way)animation-iteration-count: 3Number of runs (or infinite)animation-direction: alternatePlay forwards, then backwardsanimation-fill-mode: bothKeep the first frame during delay and the last after the endanimation-play-state: pausedPause and resumeanimation-timeline: view()Drive the animation by scroll position (scroll-driven animations)Timing functions
easeDefault: slow start, fast middle, slow endlinearConstant speed — good for spinnersease-outFast start, gentle stop — good for elements enteringease-inGentle start, fast end — good for elements leavingcubic-bezier(.2, .8, .2, 1)Custom curvesteps(8, end)Jump in discrete steps — sprite sheets, typewriter effectsTransforms
translate: 0 -8pxMove without affecting layoutscale: 1.05Grow or shrinkrotate: 45degRotatetransform-origin: top leftPivot point for scale and rotatewill-change: transformHint the browser to prepare a layer (use sparingly)Accessibility
@media (prefers-reduced-motion: reduce)Tone down or remove motion for users who ask for less@media (prefers-reduced-motion: no-preference)Only add big motion when the user has not opted out