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 trialGavin Broekema
Full Stack JavaScript Techdegree Student 22,443 PointsToo much scale for translateZ()?
Theoretical scenario:
So assume we have a perspective value 800px and a transform: scale(2) translateZ(400px); (rather than the value of 200px shown below). I'm assuming that because the translateZ value is == the perspective value, the image on the image is no longer view-able? Is this correct? Also is there any place that these styles are actually usable? Maybe 3d or virtual reality considering the image comes out of the screen??
index.html
<!DOCTYPE html>
<html>
<head>
<title>3D Transforms</title>
<link rel="stylesheet" type="text/css" href="page.css">
<link rel="stylesheet" type="text/css" href="transforms.css">
</head>
<body>
<div class="wrap">
<div class="side-a"></div>
<div class="side-b"></div>
</div>
</body>
</html>
page.css
body {
padding-top: 50px;
background: #F7F7F7;
}
.wrap {
position: relative;
margin: 0 auto;
width: 250px;
height: 350px;
cursor: pointer;
}
.wrap div {
width: 100%;
height: 100%;
border-radius: 10px;
background-position: 50% 50%;
background-size: 150px;
background-repeat: no-repeat;
box-shadow: inset 0 0 45px rgba(255,255,255,.3), 0 12px 20px -10px rgba(0,0,0,.4);
color: #FFF;
text-align: center;
text-shadow: 0 1px rgba(0,0,0,.3);
font: bold 3em sans-serif;
line-height: 350px;
}
.side-a {
background: #498FBC url('img/mike.png');
}
.side-b {
background: #33363B url('img/logo.png');
}
transforms.css
body {
-webkit-perspective: 800px;
}
.wrap {
transition: -webkit-transform 1s ease-in;
}
.wrap div {
position: absolute;
}
.side-a {
z-index: 100;
}
.wrap:hover {
-webkit-transform: scaleZ(2) translateZ(200px);
}
1 Answer
Steven Parker
231,275 PointsIf you translate to the perspective distance, you'd expect the object to fill the window, and any image on it to be extremely magnified. That's exactly what I see when I try it.
If you translate beyond the perspective distance, you see nothing, because the object is now on the other side of your viewpoint. That also works as expected.
Values that place the object on the other side of the viewpoint are no more useful than values that place the object outside of the viewing area to one side.