Moving, turning and reshaping boxes
The CSS transform property accepts a space-separated list of transform functions
that move, rotate, scale, skew or matrix-compose an element without disturbing
document flow. This reference lists every function in both 2D and 3D, with its
syntax, argument types, defaults and the practical notes that trip people up.
How it works
Transforms operate around the transform-origin (the element centre by default) and
are applied right to left: the last function in the list runs first on the
element, then each preceding function transforms the already-transformed coordinate
space. That is why translate() rotate() and rotate() translate() look different.
2D functions live in the screen plane. 3D functions add depth: translateZ,
rotateX/Y, rotate3d, scaleZ and matrix3d only show their effect once a
perspective establishes a vanishing distance — either via the perspective()
function placed first in the list or the perspective property on the ancestor.
Internally the browser collapses any chain into a single matrix, which is what you
see when you read computed styles. Filter the list above by name or dimension.
Tips and examples
- A flip is just a negative scale:
scaleX(-1)mirrors horizontally,scale(-1)mirrors both axes. translate3d(0,0,0)is a common way to promote an element to its own GPU layer for smoother animation, thoughwill-change: transformis the explicit hint.- For 3D card flips, set
perspectiveon the container,transform-style: preserve-3don the rotating element, andbackface-visibility: hiddenon the faces. - Smaller
perspective()distances exaggerate the 3D effect; large values flatten it.