skewY()
Example
.section {
transform: skewY(-4deg);
}.section { position: relative; isolation: isolate; }
.section::before {
content: '';
position: absolute;
inset: 0;
z-index: -1;
background: var(--bg);
transform: skewY(-4deg);
}Only the background is skewed, so the section gets a diagonal edge while its text stays level.
Common mistakes
- Skewing the whole section and getting tilted text.
Key points
- Diagonal section edges skew a background layer, not the section with its content.
- Extra vertical padding covers the corners that
skewY()leaves uncovered.
Interview questions
Should I use skewY() or clip-path for diagonal sections?
Both work. clip-path: polygon() cuts the edge without moving pixels, while skewY() tilts a whole layer.
Why are there gaps at the corners after skewY()?
Skewing moves the corners up and down; add vertical padding or scale the layer slightly to cover them.