Languages
[Edit]
EN

CSS - multiple transformations at once

0 points
Created by:
elmer
646

In this article, we would like to show you how to add multiple filters at the same time using CSS.

Quick solution:

.element {
    transform: translate(50px, 50px) rotate(45deg) scale(2) /* put more transforms here ... */;
}

Where:

  • transformation should be read from right to left
    It means, the object will be:
    1. scaled up 2 times (according to element size),
    2. rotated by 45 degrees (in clockwise direction around its own center),
    3. translated by [50px, 50px] (according to input position),
  • we can put more translate()rotate() and scale() transformations separating them by spaces one by one.

 

Practical example

In this example, we used translate()rotate() and scale() transformations at once.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>
    
    body {
        height: 150px;
    }

    .element {
        width: 25px;
        height: 25px;
        background: green;
        transform: translate(50px, 50px) rotate(15deg) scale(2);
    }

  </style>
</head>
<body>
  <div class="element"></div>
</body>
</html>

 

See also

  1. CSS - multiple filters at once

References

  1. transform - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - multiple transformations at the same time
  2. CSS - multiple transform filters at once
  3. CSS - multiple transform filters at the same time
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join