CSS Reference Function

matrix() p533l

The matrix() function is a 2D transform function used to specify a two-dimensional transformation matrix. 296z1v

It can be used to combine several transformations into one. For example, instead of using two (or more) transform functions (see above) in one declaration like so:

transform: rotate(45deg) translate(24px,25px);

Using the matrix() function, we can combine these two transformations into one matrix:

transform: matrix(0.7071067811865476, 0.7071067811865475, -0.7071067811865475, 0.7071067811865476, -0.7071067811865426, 34.648232278140824);

As you can see, calculating the values of the matrix() function wouldn’t be easy if you’re not math-savvy. These calculations were also probably not meant to be done by hand. Luckily, Eric Meyer and Aaron Gustafson created a very useful tool which can do the calculations for you—all you do is enter the transformations you want and the click the red button for the tool to generate the equivalent matrix() function for you.

The official syntax looks as follows:

transform: matrix( <number> [, <number> ]{5,5} )

For understanding how to use the transform function, you can read the CSS Transform entry.

Browser k5t66

The following is the table for two-dimensional CSS transformations:

CSS3 2D Transforms 291431

Method of transforming an element including rotating, scaling, etc. Includes for `transform` as well as `transform-origin` properties.

W3C Working Draft

ed from the following versions:

Desktop 3n671n

  • 36
  • 16
  • 10
  • 12
  • 9

Mobile / Tablet 4q224p

  • 9.0
  • 66
  • No
  • 66
  • 60

* denotes prefix required.

  • ed:
  • Yes
  • No
  • Partially
  • Polyfill

Stats from caniuse.com

Written by

Last updated June 11, 2020 at 9:33 pm by Mary Lou

Do you have a suggestion, question or want to contribute? Submit an issue.