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 Activate 3D Space with perspective

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points

There are some things about 3D space that don't make sense to me.

I'm having trouble wrapping my head around some things. So we have the z axis when we give it a perspective, I can accept that. What about z-index? When things have a z-index and also being on the z-axis they get very muddled for me and possibly defy the laws of nature. Also, in this workspace I tried out a little thing where we would zoom out the perspective on hover, but it didn't end up looking realistic in terms of changing perspective. It looks more like they're being stretched than that we're zooming out. Should I be doing this differently, or are there just limitations on how well we can use CSS to do fancy 3D?

.content {
  perspective: 300px;  
  transition: perspective .3s;
}

.content:hover {
  perspective: 3000px;
}


.photo {
  transform: rotateY(55deg)  
}

1 Answer

Steven Parker
Steven Parker
231,236 Points

Perspective isn't a substitute for "zoom", it's more about angles than magnification.

:point_right: For a visual "zoom" function, try scale instead. Or for a video dolly effect, try translateZ.

You might also want more than a single planar element in the view area to get a better feel for the effect.