Day 81: the order of individual transform properties
posted on
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
- Finer grained control over CSS transforms with individual transform
- Order in CSS transformations – transform functions vs individual
Overview: 100 Days Of More Or Less Modern CSS