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
With translate3d(), you can define a translation on the X, Y, and Z axes, all in one function.
Important Update
Browser rendering for 3D transforms changed since we recorded this video. If your rotating 3D cube does not look and work as it does in the video, add the following properties to the CSS rule selecting each side in interactions.css
:
.front,
.back,
.left,
.right {
width: 100%;
height: 100%;
display: block;
position: absolute;
/* New CSS */
transform-style: inherit;
backface-visibility: hidden;
}
Resources
Video review
-
translate3d()
is a shorthand function fortranslateX()
,translateY()
andtranslateZ()
. -
translate3d()
accepts three comma-separated values to move an element on the X, Y, and Z axes.
Function syntax:
translate3d(x, y, z)
The following translation on the Z-axis:
transform: translateZ(200px);
is equivalent to the shorthand:
transform: translate3d(0, 0, 200px);
Related videos and courses
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