What Is a Transform?
transform changes how an element is drawn (moved, turned, resized) without changing the space it takes in the layout. That makes it fast and smooth.
| Function | Effect | Example |
|---|---|---|
translate(x, y) | Move | translate(20px, -10px) |
rotate(angle) | Turn | rotate(45deg) |
scale(n) | Make bigger or smaller | scale(1.1) |
skew(x, y) | Slant | skewX(10deg) |
Functions apply in order, right to left in terms of the math. If results look odd, change the order.
computed transform for translate(10px, 20px) rotate(90deg) scale(2): matrix(0, 2, -2, 0, 10, 20)
transform-origin
The origin is the point the transform happens around. The default is the center.
Hover Effects
A Simple Centered Overlay
top: 50% moves the top-left corner to the middle. translate(-50%, -50%) moves the element back by half its own size, so it is truly centered.
3D Transforms
| Property | Use |
|---|---|
perspective | On the parent. Smaller value means stronger 3D |
transform-style: preserve-3d | Children keep their 3D position |
backface-visibility: hidden | Hide the back of a flipped face |
@media (prefers-reduced-motion: reduce).
Practice
- Make a card that lifts on hover
- Center a badge with the translate trick
- Build a card that flips on hover
Conclusion
Transforms move, turn and scale elements smoothly. Use them for hover effects and respect reduced motion.

