skewX()
Example
.tab {
transform: skewX(-20deg);
}.tab {
transform: skewX(-20deg);
}
.tab > span {
display: inline-block;
transform: skewX(20deg);
}The inner span undoes the skew, so the tab is slanted but the text is not.
Common mistakes
- The label of a slanted tab looks italic and blurry.
Key points
- Text inside a
skewX()parent is counter-skewed with the opposite angle. - Angles near '90deg' are avoided, because the element stretches to infinity.
Interview questions
Why does my counter-skew not work on a span?
Transforms do not apply to plain inline elements. Set display: inline-block on the span first.
Is skewX() the same as skew() with one value?
Yes. skew(20deg) and skewX(20deg) give the same result.