Today I Learned - Rocky Kev

TIL individual transform CSS

POSTED ON:

TAGS:

We now have individual transform CSS!

Currently, in order to apply transforms, you do something like this:

div {
/* These transform functions are applied from left to right. */

transform: translate(50%, 0) scale(1.5);
}

.square {
/* scale -> translate */
transform: scale(1.5) translate(50%, 0);
}

By moving these into individual transforms, they look like this and follow a execution order.

div {
/* Follows a pattern: translate -> rotate -> scale */
translate: 50% 0;
scale: 1.5;
}

.square {
/* translate -> scale */
translate: 50% 0;
scale: 1.5;
}

To ensure support, you would use:

@supports (translate: 0) {
/* Use `translate` */
}

@supports not (translate: 0) {
/* Use `transform: translate()` */
}

via Order in CSS transformations – transform functions vs individual transforms


Related TILs

Tagged:

TIL individual transform CSS

We now have individual transform CSS!

TIL individual transform CSS

We now have individual transform CSS!

TIL individual transform CSS

We now have individual transform CSS!