更改 CSS 变换旋转轴? [英] Change CSS transform rotation axis?

查看:55
本文介绍了更改 CSS 变换旋转轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很长时间,并得到了 SO 的大量帮助来构建这个立方体,并将面设为 Z:0,因此正好是 200x200 像素.我希望它旋转,以便所有面都是 200x200 并且位于相同的位置.

It took me a long time and lots of help from SO to build this cube and get the face to Z:0 and therefore exactly 200x200 pixels. I would like it to rotate so that all faces are 200x200 and in the same position.

小提琴:http://jsfiddle.net/scottbeeson/phJpS/7/

相对 CSS:

.itemView {
    -webkit-perspective:2000;
    -webkit-margin-start: 0 !important;
    -webkit-margin-before: 0 !important;
    -webkit-margin-end: 0 !important;
    -webkit-margin-after: 0 !important;
}

.cube {
    position: absolute;
    -webkit-transform-style: preserve-3d;
    -webkit-transition: -webkit-transform 1s;
}

.cube figure {
    display: block;
    position: absolute;
    width: 198px;
    height: 198px;
    border: 0px solid black;
    color: white;
    margin: 0px;
    padding: 0px;
}

.cube.panels-backface-invisible figure {
    -webkit-backface-visibility: hidden;
}

.cube .front  {     
    background-color: #555;
    border: 1px solid #ccc; 
}
.cube .back   {
    background-color: #555;
    border: 1px solid #ccc;
}
.cube .right  { 
    background-color: #555;
    border: 1px solid #ccc;
}
.cube .left   { 
    background-color: #555;
    border: 1px solid #ccc;
    }
.cube .top    {
    background-color: #555;
    border: 1px solid #ccc;
    }
.cube .bottom { 
    background-color: #555;
    border: 1px solid #ccc;
    }

.cube .front  {
    -webkit-transform: translateZ(0px );
}
.cube .back   {
    -webkit-transform: rotateX( -180deg ) translateZ( 200px );
}
.cube .right {
    -webkit-transform: rotateY(   90deg ) translateZ( 100px ) translateX(100px);
}
.cube .left {
    -webkit-transform: rotateY(  -90deg ) translateZ( 100px) translateX(-100px);
}
.cube .top {
    -webkit-transform: rotateX(   90deg ) translateZ( 100px ) translateY(-100px);
}
.cube .bottom {
    -webkit-transform: rotateX(  -90deg ) translateZ( 100px ) translateY(100px);
}

.cube.show-front {
    -webkit-transform: translateZ( 0px );
}
.cube.show-back {
    -webkit-transform: rotateX( -180deg );
}
.cube.show-right {
    -webkit-transform: rotateY(  -90deg );
}
.cube.show-left {
    -webkit-transform: rotateY(   90deg );
}
.cube.show-top {
    -webkit-transform: rotateX(  -90deg );
}
.cube.show-bottom {
    -webkit-transform: rotateX(   90deg );
}

推荐答案

你没有给我时间回答另一个问题 :-)

You didn't left me time to answer in the other question :-)

我的意思是在立方体下添加另一个级别,名为 base.然后在 Z 平面上应用一个运动:

What I was meaning was to add another level, under the cube, named base. And there apply a movement in the Z plane:

.base {
     width: 100%;
     height: 100%;
     position: absolute;
     -webkit-transform-style: preserve-3d;
        -moz-transform-style: preserve-3d;
          -o-transform-style: preserve-3d;
             transform-style: preserve-3d;
     -webkit-transform: translateZ(-100px );
}

这样,演示的所有其余部分都可以运行,您可以轻松地将立方体移动到您想要的位置.

This way, all the rest of the demo works, and you can easily move the cube where you want.

这篇关于更改 CSS 变换旋转轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆