CSS | matrix() Function

The matrix() function is an inbuilt function which is used to create a homogeneous 2D transformation matrix.

Syntax:

matrix( a, b, c, d, tx, ty )

Parameters: This function accepts six parameters as mentioned above and described below:



  • a, b, c, d: These parameters are used to describe the linear transformation.
  • tx: This parameter is used to describe the linear translation on x-axis.
  • ty: This parameter is used to describe the linear translation on y-axis.

Below example illustrates the matrix() function in CSS:
Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      CSS matrix() function
  </title>
    <style>
        body {
            text-align: center;
        }
          
        h1 {
            color: green;
        }
          
        .GFG {
            transform-origin: 0 0;
            transform: matrix(0.8, 0.8, -0.8, 0.8, 250, -30);
            font-size: 26px;
            font-weight: bold;
            width: 250px;
            padding: 20px;
            background: green;
            color: white;
            font-family: sans-serif;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h2>CSS matrix() function</h2>
    <br>
    <br>
  
    <div class="GFG">
      Welcome to GeeksforGeeks
  </div>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by matrix() function are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.