skewX()

Term side of the Card.
Topic: Transformations
Unit title: skewX()
Categories: Function
Explanation side of the Card

Explanation: The function that skews an element horizontally along the X-axis. It slants the element left or right, distorting its shape and creating an effect as though the element is being pushed sideways.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 3.5.
  • The safari browser supports this feature starting from version 3.1.
Availability: 

Example

Wrongcss
.tab {
  transform: skewX(-20deg);
}
Rightcss
.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.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy