Skip to content

2D Transforms: Rotate, Scale, Translate, and Skew

These four transforms are the foundation of everything that comes next. We’ll keep each one clean and obvious, with a ghost object showing the original position.


translate() shifts an element on the X and/or Y axis without affecting layout flow of elements around it.

Monkey moved right and slightly up to demonstrate translate.

Ghost = original position. Solid = translated.

.monkey {
transform: translate(70px, -30px);
}

rotate() turns an element around an axis.

The default axis is Z, the one pointing right at us.

The value is in degrees, clockwise, expressed from (0deg) to (360deg) and beyond.

We can also rotateX() and rotateY().

Monkey rotated clockwise to demonstrate rotate.

Rotation around a pivot (origin).

(We’ll dive into origin stories, very soon)

.monkey {
transform: rotate(45deg);
}

scale() changes visual size without changing layout size.

It’s the not-at-all-pushy way to grow.

Monkey increased in size to demonstrate scale.

Layout space stays the same — only the pixels grow.

.monkey {
transform: scale(0.65);
}

skew() slants an element along X and/or Y.

We can provide both X and Y values with skew(x, y), or we can skewX() or skewY().

There is no skewZ(). For that we’d need to enter the matrix3d(), and we’re in flatland here.

Monkey slanted to demonstrate skew.

Skew is subtle in real UI — dramatic here so it’s obvious.

.monkey {
transform: skew(-14deg, 6deg);
}

We can transform: multiple things at a time.

Individual transforms are separated by space and applied in sequence.

Monkey transformed with translate, rotate, and scale.
.monkey {
transform: translate(40px, -10px) rotate(12deg) scale(1.1);
}

Order matters. We’ll we why when we talk assemblies.