Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS - Beyond the Basics CSS Animation Basics Full-Page Animation Project: Part 1

Why did Guil use rotateZ and not a normal rotate? For the GPU acceleration boost?

Guil uses rotateZ for rotating the steam. I wonder why he is using a 3D transformation although we are working in a 2D space. Only for the GPU boost? By what exactly does that get triggered? Is using the 3D transform functions always better?

2 Answers

Codin - Codesmite
Codin - Codesmite
8,600 Points

There is no difference in what they do, they both rotate on the z axis. But I believe rotateZ does trigger hardware acceleration in webkit browsers as it utilizes the GPU instead.

For example you can actually trigger hardware acceleration on 2D transforms by including a 3D transform even if the value is set to 0.

#example{
   transform: rotate(90deg) translateZ(0);
}

The above code would trigger hardware acceleration due to translateZ();

This allows you to have a 2D rotate that is backwards compatible with browsers that do not support 3D CSS transforms. and also at the same time enable hardware acceleration in browsers that do. translateZ(0); will not break the rotate in browsers that are not compatible with 3D Transforms.

You can do this with any of the 3D CSS transforms:

    translate3d()
    translateZ()
    scale3d()
    scaleZ()
    rotateX()
    rotateY()
    rotate3d()
    perspective()
    matrix3d()

Sweet, that's what I thought. Thanks for clarifying, Ashley!