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
DDDOriginal
2024-12-27 06:29:13935browse

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);
}

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);

is different from:

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

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);
}

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!

Statement:
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
Previous article:HTML Formatting TagsNext article:HTML Formatting Tags