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 - Beyond the Basics Understanding CSS Transitions and Transforms 3D Transforms: transform-style and backface-visibility

Gavin Broekema
seal-mask
.a{fill-rule:evenodd;}techdegree
Gavin Broekema
Full Stack JavaScript Techdegree Student 22,443 Points

rotateY(180deg) vs. rotateY(-180deg)

When I set the transform: rotateY() value to -180deg vs 180deg, the image disappears momentarily before returning to its normal state (after hovering and allowing the initial transform to happen). Can someone explain why this happens? It was not explained in the video, but I may just be missing something.

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>

transforms.css

body {
    -webkit-perspective: 800px;
}

.wrap {
    transition: -webkit-transform 1s ease-in;
    transform-style: preserve-3d;
}

.wrap div {
    position: absolute;
    backface-visibility: hidden;
}

.side-a {
    z-index: 100;
}

.side-b {
  transform: rotateY(-180deg);
}


.wrap:hover {
    -webkit-transform: rotateY(-1turn);
}

1 Answer

Steven Parker
Steven Parker
231,275 Points

I don't see it. Setting 180 or -180 look exactly the same here.

Now if you set it to something like 140 it will disappear as it passes through the part of the rotation where both of the suppressed backfaces are forward.