CSS3 transform: translate3d doesn't affect the z-axis?

4.9k views Asked by At

I have this snippet implemented:

CSS

div
{
    position:absolute;
    -webkit-transition: all 0.3s ease-out;
}
.block
{
    background:#fc0; /* YELLOW */
    top:50px;
    left:50px;
    width:80px;
    height:40px;
    -webkit-transform: rotate3d(1,0,0,-55deg) rotate3d(0,0,1,30deg);
}
.block .part
{
    background:#444; /* GREY */
    width:inherit;
    height:inherit;
    -webkit-transform: translate3d(0,0,50px);
}
.block:hover .part
{
    -webkit-transform: translate3d(10px,10px,20px); /* ONLY TRANSFORMS X & Y */
}

HTML

<div class="block">
    <div class="part"></div>
</div>

Check out this Fiddle for the live example.

As you can see, the translation on :hover only affects the .part on the x- and y-axis.

It won't translate in the z-direction.

Anyone who knows what I'm doing wrong?

1

There are 1 answers

0
Kriem On BEST ANSWER

Got it. Forgot to add -webkit-transform-style: preserve-3d;