2D Transforms: translate, rotate, scale, skew
- CSS Basics
- Selectors & Specificity
- Box Model & Units
- Typography & Text Styling
- Colors & Color Spaces
- Positioning & Stacking Context
- Flexbox
- Grid
- Grid Advanced
- Responsive Design
- Container Queries
- Pseudo-classes & Pseudo-elements
- Modern Selectors
- CSS Custom Properties
- CSS Functions
- Transitions & Animations
- Transforms
- Forms & Input Styling
- CSS Architecture & Methodologies
- Accessibility in CSS
- Performance & Optimization
- View Transitions & Modern APIs
- Cascade Layers & Scope
What the transform Property Does
transform visually moves, rotates, resizes or skews an element without affecting the layout of surrounding elements - unlike changing width or margin, which pushes neighboring content around.
translate: Moving an Element
.box {
transform: translate(20px, -10px); /* right 20px, up 10px */
}Positive values move right/down; negative values move left/up. translateX() and translateY() can also be used individually.
rotate: Turning an Element
.icon {
transform: rotate(45deg);
}scale: Resizing an Element
.card:hover {
transform: scale(1.05); /* 5% larger, both axes */
}
.badge {
transform: scale(1.2, 0.9); /* different scale per axis */
}skew: Slanting an Element
.ribbon {
transform: skew(-10deg, 0deg);
}Skew shears an element along an axis, commonly used for stylized ribbon or banner shapes.
Combining Several Transforms Together
.card:hover {
transform: translateY(-4px) scale(1.02);
}Multiple transform functions can be listed in one declaration, applied in the order written - reordering them can change the visual result, since each transform is applied relative to the coordinate space left by the one before it.