4

I am attempting to combine two css 3d transforms from one being applied to a parent and one being applied to a child to a single unified one being applied to the child to increase performance. So, my question is this: what am I missing in the below calculation.

parent {
    transform-style: preserve-3d;
    transform: translateY(50vh) translateZ(-50vh) rotateX(90deg) rotateY(180deg) rotateZ(180deg);
}
                                     +
child {
    transform: translateZ(-100vh) rotateX(90deg);
}
                                 and I got
combined {
    transform: translateY(50vh) translateZ(-150vh) rotateX(180deg) rotateY(180deg) rotateZ(180deg);
}

What went wrong when I added the matrixes?

0

1 Answer 1

1

You can not sum similar transforms. You need to concatenate all of them.

Well, there are special cases, but most of the time this is true

The result would be

child {
transform: translateY(50vh) translateZ(-50vh) rotateX(90deg) rotateY(180deg) rotateZ(180deg) 
           translateZ(-100vh) rotateX(90deg);

}

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this worked perfectly. Also, thank you for teaching me something new about css: that you can have multiple of the same transforms in one statement. The more you know....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.