Home > Web Front-end > CSS Tutorial > How to Apply Multiple CSS Transforms in One Line and What's the Order of Application?

How to Apply Multiple CSS Transforms in One Line and What's the Order of Application?

DDD
Release: 2024-12-27 06:29:13
Original
879 people have browsed it

How to Apply Multiple CSS Transforms in One Line and What's the Order of Application?

Applying Multiple CSS Transforms in One Line

In CSS, you can apply multiple transforms to an element simultaneously. However, if you provide multiple transform directives, only the last one will be applied.

To apply multiple transforms on one line, concatenate them with spaces:

li:nth-child(2) {
    transform: rotate(15deg) translate(-20px,0px);
}
Copy after login

Order of Application

It's crucial to note that multiple transforms are applied from right to left. This means the order of transforms matters, as:

transform: scale(1,1.5) rotate(90deg);
Copy after login

is different from:

transform: rotate(90deg) scale(1,1.5);
Copy after login

Example

Consider the following example:

.orderOne, .orderTwo {
    font-family: sans-serif;
    font-size: 22px;
    color: #000;
    display: inline-block;
}

.orderOne {
    transform: scale(1, 1.5) rotate(90deg);
}

.orderTwo {
    transform: rotate(90deg) scale(1, 1.5);
}
Copy after login

You can observe the difference by applying the transforms in different orders.

The above is the detailed content of How to Apply Multiple CSS Transforms in One Line and What's the Order of Application?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template