CSS Transform Generator

Translate, rotate, scale, skew and 3D perspective on one panel. The dashed outline marks where the element started, which makes the order of transforms easy to see.

Aa

CSS Transforms Explained: Rotate, Scale, Translate, Skew and 3D

transform is one of the most useful properties in CSS. It moves, rotates, scales and skews elements without affecting the layout around them, and it’s the foundation of almost every smooth animation on the web. Understanding a few rules, especially about order and origin, makes transforms predictable instead of surprising.

CSS transforms rotate, scale and skew with dashed outlines of the original positions

The 2D functions

FunctionExampleEffect
translate(x, y)translate(20px, -10px)Moves the element
rotate(angle)rotate(15deg)Rotates clockwise (negative = counter-clockwise)
scale(x, y)scale(1.1)Grows or shrinks; one value scales both axes
skew(x, y)skew(10deg, 0)Slants the element along an axis
matrix(a, b, c, d, e, f)—All of the above in one matrix

Percentages in translate() are relative to the element’s own size, not its parent. That’s why translate(-50%, -50%) became the classic way to centre an absolutely positioned element of unknown size.

Transforms don’t affect layout

A transformed element still occupies its original space in the layout. Neighbouring elements don’t move when you scale or rotate it. That makes transforms safe for hover effects, but it also means a scaled-up element can overlap its neighbours. Use z-index or a little extra spacing if needed.

Order matters

When you write several functions, they are applied from right to left in terms of the coordinate system, which means each function works in the coordinate space created by the ones before it. In practice:

transform: translate(100px, 0) rotate(45deg);  /* moves right, then rotates in place */
transform: rotate(45deg) translate(100px, 0);  /* rotates, then moves along the rotated axis */

The first moves the element 100px to the right and rotates it. The second rotates the element’s coordinate system, then moves it 100px along the rotated x-axis, so it ends up diagonally down-right. Neither is wrong, but they are different. The CSS transform generator above uses a fixed, predictable order and shows a dashed outline of the original position so you can see exactly what each change does.

Individual transform properties

Modern CSS also has separate translate, rotate and scale properties:

.card { translate: 0 -4px; rotate: 2deg; scale: 1.02; }

They are always applied in the order translate, rotate, scale, regardless of how you write them, and they can be animated independently, which is handy when a hover effect and an entrance animation both want to change different parts of the transform. They have been supported in all major browsers since 2022.

transform-origin

Rotation, scaling and skewing happen around a pivot point, set by transform-origin. The default is the center (50% 50%).

OriginRotation effect
centerSpins in place
top leftSwings like a door hinged at the top-left corner
bottomTips over from the bottom edge
0 0 in SVGSVG elements default to the top-left of the SVG canvas, a common surprise

For example, a dropdown menu that scales in from transform-origin: top looks like it unfolds from its trigger, which feels more natural than growing from the center.

3D transforms

Add a third dimension with rotateX, rotateY, translateZ and their relatives. For 3D to look like 3D, you need perspective, which controls how strong the depth effect is:

  • transform: perspective(800px) rotateY(30deg) applies perspective to one element.
  • perspective: 800px on a parent gives all children a shared vanishing point, so a set of cards looks like they live in the same 3D space.

Smaller perspective values (200–400px) create dramatic distortion, like viewing from very close. Larger values (1000px+) are subtle. Card flips use rotateY(180deg) with backface-visibility: hidden on both faces, and transform-style: preserve-3d on the container so the children keep their 3D positions.

Why transforms are the property to animate

Browsers render a page in stages: style, layout, paint and composite. Changing width, top or margin triggers layout, which can force the browser to recalculate positions for many elements on every frame. Changing transform or opacity can usually skip layout and paint, and be handled by the compositor, often on the GPU.

Animated propertyTriggersSmoothness on mobile
left, top, width, height, marginLayout + paint + compositeOften janky
background-color, box-shadowPaint + compositeUsually OK for small elements
transform, opacityComposite only (typically)Smooth

So instead of animating left: 0 to left: 200px, animate transform: translateX(200px). Pair it with good easing from our cubic-bezier guide and motion feels polished.

will-change: transform can hint to the browser to prepare a separate layer in advance, but use it sparingly; too many layers consume memory.

Hover lifts, zooms and flips

  • Lift on hover: transform: translateY(-2px) with a slightly stronger shadow.
  • Gentle zoom on image hover: wrap the image in an overflow: hidden container and apply scale(1.05) to the image.
  • Icon rotation: rotate(180deg) on a chevron when an accordion opens.
  • Centering: position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%).
  • Mirror: scale(-1, 1) flips an element horizontally.

Text and skew

Skew distorts letterforms, so skewed text quickly becomes hard to read. A popular trick for slanted buttons or banners is to skew the container and then un-skew the text inside with the opposite angle, keeping the label upright.

Motion sensitivity and prefers-reduced-motion

Large movements, zooms and spins can cause discomfort for people with vestibular disorders. Wrap non-essential transform animations in a prefers-reduced-motion check and keep them small and short. Also remember that rotated or skewed text can be difficult to read for everyone; keep body text unrotated.