CSS Reference ยท Transforms, Transitions and Animations
The rotate property
Reference for the CSS rotate property: turn an element with its own property, using an angle or an axis and angle for 3D, independent from transform.
The rotate property turns an element by an angle. It does the same job as the rotate() functions in transform, but lives in its own property, so you can change or animate the rotation without touching any translation or scale.
By default the turn happens around the center of the element; change the pivot with transform-origin. Positive angles turn clockwise.
.icon { rotate: 45deg; }
Try it
Syntax
rotate: none | <angle> | [ x | y | z | <number>{3} ] && <angle>;
- Initial value:
none - Applies to: transformable elements
- Inherited: no
- Animatable: yes
- Computed value:
none, or an axis and angle
Values
| Value | Description |
|---|---|
<angle> |
A 2D rotation (around the z axis): 45deg, 0.25turn, 1.5rad, 100grad. |
x, y, z with <angle> |
Rotate around that axis, like rotateX(); rotate: y 40deg flips toward or away from the viewer. |
Three numbers with <angle> |
A custom axis vector, e.g. rotate: 1 1 0 45deg. |
none |
No rotation. |
Usage notes
- Application order.
translateis applied first, thenrotate, thenscale, thentransform. - Animating more than a half-turn. Between
0degand360degthe browser interpolates the full angle, sorotate: 360degis a spin. Animating withturnunits reads clearly (1turn). - Interpolating from
nonetreats it as a zero rotation, so it animates smoothly. - 3D needs perspective. An axis rotation looks flat without
perspectiveon the element's parent. - Side effects are the same as for
transform: stacking context, new containing block for fixed descendants, layout unchanged. - Accessibility. Constant spinning can trigger discomfort; stop it under
prefers-reduced-motion.
Browser support
Individual transform properties are newer than transform. They work in current versions of the major browsers, but check a compatibility table when supporting older ones.
Related
translate,scaletransform,transform-origin- Lessons: 2D Transforms, 3D Transforms