Day 81: the order of individual transform properties
source link: https://www.matuzo.at/blog/2023/100daysof-day81/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Day 81: the order of individual transform properties
posted on January 13., 2023
It’s time to get me up to speed with modern CSS. There’s so much new in CSS that I know too little about. To change that I’ve started #100DaysOfMoreOrLessModernCSS. Why more or less modern CSS? Because some topics will be about cutting-edge features, while other stuff has been around for quite a while already, but I just have little to no experience with it.
On day 66, I’ve introduced you to individual transform properties. An interesting detail about these properties is the order in which transforms are applied compared to the transform
property.
If you use the transform
property, transformation functions are applied in the order of appearance, from left to right.
<button class="button1">Button 1</button>
<button class="button2">Button 2</button>
.button1 {
transform: translateX(50px) scale(1.5);
}
.button2 {
transform: scale(1.5) translateX(50px);
}
With individual transform properties, the order of appearance of the declarations doesn’t matter. The order is always the same: translate
–> rotate
–> scale
.
.button3 {
translate: 50px 0;
scale: 1.5;
}
.button4 {
scale: 1.5;
translate: 50px 0;
}
If you mix transform
and individual properties, individual transforms get applied first.
.button5 {
transform: translateX(50px);
scale: 1.5;
}
.button6 {
transform: scale(1.5);
translate: 50px 0;
}
Further reading
Want more?
Overview: 100 Days Of More Or Less Modern CSS
My blog doesn't support comments yet, but you can reply via e-mail.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK