Transforms in CSS
Moving, scaling and rotating a box without touching layout.
.card:hover {
transform: translateY(-4px) scale(1.02);
}
.chevron {
transform-origin: center;
rotate: 0deg;
transition: rotate 150ms ease;
}
details[open] .chevron {
rotate: 90deg;
}
.badge {
transform: translate(-50%, -50%) rotate(-8deg);
}
How it works
- Transforms compose left to right, so order matters.
transform-originmoves the point everything pivots around.- Individual properties like
rotatecan be animated separately.
Keywords and builtins used here
badgecardchevrondegmspxrotatescaletransformtransitiontranslatetranslateY
The run, in numbers
- Lines
- 17
- Characters to type
- 244
- Tokens
- 71
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 47 seconds.
Step 4 of 8 in Motion & effects, step 14 of 21 in Responsive & modern CSS.