bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS 2D Transform Skew / Matrix

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

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

The CSS skewX() FunctionThe CSS skewY() FunctionThe CSS skew() FunctionThe CSS matrix() FunctionCSS Transform PropertiesCSS 2D Transform Functions