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

拜拜、爱过 提交于 2019-12-12 09:26:15

问题


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:


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



来源:https://stackoverflow.com/questions/8835415/css3-transform-translate3d-doesnt-affect-the-z-axis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!