bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS 2D Transform Skew / Matrix

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind CSS 2D Transform Skew / Matrix?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___: skewX(20deg);
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The CSS skew() Function
The CSS skewY() Function
The CSS skewX() Function

The CSS skewX() Function

The skewX() function skews an element along the X-axis by the given angle.

The following example skews the <div> element 20 degrees along the X-axis:

Example

Formatted code
div {
  transform: skewX(20deg);
}

Live preview

The CSS skewY() Function

The skewY() function skews an element along the Y-axis by the given angle.

The following example skews the <div> element 20 degrees along the Y-axis:

Example

Formatted code
div {
  transform: skewY(20deg);
}

Live preview

The CSS skew() Function

The skew() function skews an element along the X and Y-axis by the given angles.

The following example skews the <div> element 20 degrees along the X-axis, and 10 degrees along the Y-axis:

Example

Formatted code
div {
  transform: skew(20deg, 10deg);
}

Live preview

If the second parameter is not specified, it has a zero value. So, the following example skews the <div> element 20 degrees along the X-axis:

Example

Formatted code
div {
  transform: skew(20deg);
}

Live preview

The CSS matrix() Function

The matrix() function combines all the 2D transform functions into one.

The matrix() function take six parameters, containing mathematic functions, which allows you to rotate, scale, move (translate), and skew elements.

The parameters are as follow: matrix(scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY())

Example

Formatted code
div {
  transform: matrix(1, -0.3, 0, 1, 0, 0);
}

Live preview

CSS Transform Properties

The following table lists all the 2D transform properties:

PropertyDescription
transformApplies a 2D or 3D transformation to an element
transform-originAllows you to change the position on transformed elements

CSS 2D Transform Functions

FunctionDescription
matrix()Defines a 2D transformation, using a matrix of six values
translate()Defines a 2D translation, moving the element along the X- and the Y-axis
translateX()Defines a 2D translation, moving the element along the X-axis
translateY()Defines a 2D translation, moving the element along the Y-axis
scale()Defines a 2D scale transformation, scaling the elements width and height
scaleX()Defines a 2D scale transformation, scaling the element's width
scaleY()Defines a 2D scale transformation, scaling the element's height
rotate()Defines a 2D rotation, the angle is specified in the parameter
skew()Defines a 2D skew transformation along the X- and the Y-axis
skewX()Defines a 2D skew transformation along the X-axis
skewY()Defines a 2D skew transformation along the Y-axis

Previous

CSS 2D Transform Scale

Next

CSS 3D Transforms