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

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

What is happening

Can somebody please explain me what is happening after 5.00 minute, It is freaking me out, nothing is explained, .front how it moving we did not have the hover option and what is happening how I mean how it is going like that?

2 Answers

Let's try this: Imagine that you are holding 2 pictures in one of your hands in front of you, with both pictures facing you (you'll only be able to see the one in front). For this mental exercise, we'll assume the pictures are 6 inches wide.

Now, take the picture that is the "back" picture and put it in your left hand, and put the "front" picture in your right hand. Bring your right hand towards you 3 inches and move your left hand away from you 3 inches. This represents the translateZ() on the .front and .back classes.

Now, hold the picture in your left hand by the middle of the left edge of the picture. This represents the transform-origin: center left.

(This next part would be very difficult to do physically, but try to imagine it anyway.) While holding the left edge of that card, (making sure you keep that point in the same place) rotate the photo away from you. Keep rotating it until the right edge of the photo touches the left edge of the front photo, and the picture is facing to your left. This is the rotate(270deg). Now, in your hands, you have half of a box, with one side being a photo that you can see, and one side has a photo facing to your left.

Now, when you do the hover, the photos will rotate -270deg, so you are going to have the one that is currently facing to your left facing you, and the one that is currently facing you will be facing to your right. (Keep in mind that -270deg is the same as 90deg).

Hopefully this helps you get a better mental picture of what is happening.

The hover is defined on the photo-cube class, which is the parent for the image. Check the video again at 3:00.

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

Hey Jason, thankyou for letting me know I checked the video 3 times the part after 5.00 mins, I am unable to understand that like how and what he is doing he has not explained anything like why and how is that working .back{ transform: translateZ(-110px) rotate(270deg) transform-origin: center left; } It has took way more time for me to understand how and what did happen, how everything rolled up to exact place