Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In 3D space you can rotate elements in multiple directions at once. CSS has a rotate3d() function that provides a way to perform a 3D rotation on the X, Y, and Z axes.
Resources
Video review
-
rotateZ()
is a 3D function that rotates elements on the Z-axis. - With
rotate3d()
, you can rotate on the X, Y, and Z axis at the same time. -
rotate3d()
accepts four comma-separated values. - The first three values set the direction of the rotation on the x, y, and z axes; the fourth value sets the rotation angle.
rotate3d(x, y, z, <angle>)
Changing a value from 0
to 1
lets the browser know that you want to rotate the element on that particular axis. For example, this rotates .photo
45 degrees on the X-axis only:
.photo:hover {
transform: rotate3d(1, 0, 0, 45deg);
}
rotate3d()
makes working with 3D rotations convenient because you can efficiently set multiple rotations with one function.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up