CSS 2D transforms visually move, rotate, resize, or tilt an element without changing the normal layout space around it. This is why transforms are popular for hover effects: the element can lift or grow without pushing nearby content away.
Transforms are also performance-friendly when used with opacity because browsers can often animate them on the compositor layer. Still, they should be subtle in UI controls so users do not feel the interface jumping under the pointer.
CSS 2D transforms let you move, rotate, scale, or skew an element in a two-dimensional plane. They change how an element is rendered visually without necessarily changing the surrounding document flow.
Transforms are commonly used for hover effects, UI feedback, micro-interactions, and visual positioning tweaks.
| Function | Purpose | Example |
|---|---|---|
| translate() | Moves an element | transform: translate(20px, 10px); |
| rotate() | Rotates an element | transform: rotate(15deg); |
| scale() | Resizes an element visually | transform: scale(1.1); |
| skew() | Tilts an element | transform: skew(10deg, 0); |
.card:hover {
transform: translateY(-6px);
}
.logo:hover {
transform: rotate(8deg);
}
.button:hover {
transform: scale(1.05);
}
.banner {
transform: skew(-10deg);
}
You can combine multiple transform functions in a single declaration. They are applied from right to left, so order matters.
The transformed element keeps its original layout slot. For example, transform: scale(1.2) makes the element look larger, but nearby elements still behave as if it kept its original size.
.product-card:hover {
transform: translateY(-8px) scale(1.02);
}
Use transform-origin when the movement should pivot around a specific point. A badge may scale from its center, a menu may open from the top-left corner, and a card flip may rotate around its middle.
.menu {
transform-origin: top left;
transform: scale(0.95);
opacity: 0;
transition: transform 160ms ease, opacity 160ms ease;
}
.menu.is-open {
transform: scale(1);
opacity: 1;
}
.lesson-box:empty::before {
content: "CSS 2D Transforms translate rotate scale skew: add visible content";
}
No. They change visual rendering, but they do not usually cause surrounding elements to reposition.
Because <code>translate()</code>, <code>rotate()</code>, and <code>scale()</code> are applied in sequence, and changing the order can produce a different visual result.
For most UI motion, <code>transform</code> is the better choice because it is smoother and avoids layout recalculation.
Explore 500+ free tutorials across 20+ languages and frameworks.