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 Transitions and Transforms Adding 3D Effects with CSS Build a Rotating 3D Cube

3D Cube is not okay!

Hi guys. For some reason my cube doesn't look like what it should be. One of the sides is not correct.

I reviewed all the code and everything seems to be okay!

What's wrong? Please someone help me! Thanks.

/* ================================= Button Transitions ==================================== */

.button { transition: background .3s; }

.button:hover { background: rgba(74, 137, 202, 1); }

/* ================================= Photo 3D Transforms & Transitions ==================================== */

.cube-container { box-shadow: 0 18px 40px 5px rgba(0,0,0,.4); perspective: 800px; }

.photo-cube { transition: transform 2s ease-in-out; width: 220px; height: 200px; transform-style: preserve-3d; }

.photo-cube:hover { transform: rotateY(-270deg); }

.front, .back, .left, .right { width: 100%; height: 100%; display: block; position: absolute; }

.front { transform: translateZ(110px); /* 50% da Width */ }

.back { transform: translateZ(-110px) rotateY(270deg); transform-origin: center left; }

.left { transform: rotateY(-270deg) translateX(110deg); transform-origin: top right; }

.right { transform: translateZ(-110px) rotateY(180deg); }

1 Answer

Brendan Strong
Brendan Strong
9,975 Points

In your .left selector, where your translateX() function is, you put 110deg instead of 110px. Gotta love those tiny little errors that make a world of difference!

Here is your code corrected:

/* ================================= Button Transitions ==================================== */

.button { transition: background .3s; }

.button:hover { background: rgba(74, 137, 202, 1); }

/* ================================= Photo 3D Transforms & Transitions ==================================== */

.cube-container { box-shadow: 0 18px 40px 5px rgba(0,0,0,.4); perspective: 800px; }

.photo-cube { transition: transform 2s ease-in-out; width: 220px; height: 200px; transform-style: preserve-3d; }

.photo-cube:hover { transform: rotateY(-270deg); }

.front, .back, .left, .right { width: 100%; height: 100%; display: block; position: absolute; }

.front { transform: translateZ(110px); /* 50% da Width */ }

.back { transform: translateZ(-110px) rotateY(270deg); transform-origin: center left; }

.left { transform: rotateY(-270deg) translateX(110px); transform-origin: top right; }

.right { transform: translateZ(-110px) rotateY(180deg); }

Details really matter. Thanks for your help! :)