CSS transform Property Explained
What the CSS transform property does, with an example.
Published November 5, 2026
transform changes an element's visual shape without affecting layout: translate, rotate, scale and skew. It is GPU-friendly and ideal for animation.
How it works
Transforms do not move neighbouring elements. transform-origin sets the pivot point. Multiple transforms apply right to left in the order written.
3D transforms need perspective.
Values and effects
transform: translate(20px, 10px); → move
transform: rotate(45deg); → rotate
transform: scale(1.2); → enlarge
transform: skewX(10deg); → slant
Practical examples
Hover lift
.card { transition: transform .2s; }
.card:hover { transform: translateY(-4px) scale(1.02); }Centre absolutely
.c { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }Spinner
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }Common mistakes
- Animating top/left instead of transform (janky).
- Forgetting transform creates a stacking context.
- Order of transform functions changing the result.
Key takeaways
- transform in one line: transform changes an element's visual shape without affecting layout: translate, rotate, scale and skew.
- Inspect it live in DevTools → Styles.
- Test across browsers and screen sizes.
FAQ
Does transform affect layout?
No, the original space is preserved.
Is transform supported in all browsers?
Yes in all modern browsers; check caniuse.com for edge cases.