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 Unused CSS Stages CSS Animations Full-Page Animation Project: Part 1

Lucas Krause
Lucas Krause
19,924 Points

rotate() vs. rotateZ()

Why is Guil using rotate() in the rock-boat animation but rotateZ() in the steam animation?
What's the difference between these two transform functions? I already read the MDN documentation on transform functions but unfortunately it didn't help me a lot.

Sure, I know that rotateZ() is more common when using 3D transformations, but when toggling the comments in the following JSFiddles I can't see any difference between the results:

2 Answers

Peter Szerzo
Peter Szerzo
22,661 Points

Lucas,

They do the exact same thing. rotateZ means 'rotate about the Z axis', and the Z axis points 'outwards from your screen'. [[ you use the same z-axis when you define a property called the z-index. If two elements overlap and one of them has a higher z-index, that one will be in the front ]]

Here is a w3c link that explains more, including browser support: http://www.w3schools.com/css/css3_3dtransforms.asp

Peter

Lucas Krause
Lucas Krause
19,924 Points

Thanks for confirming my assumption :)

Lucas Krause
Lucas Krause
19,924 Points

As it turns out rotateZ() is really the same as rotate(). It's also stated in the specification:

rotateZ() = rotateZ( <angle> )
same as rotate3d(0, 0, 1, <angle>), which is also the same as rotate(<angle>).