我对已经旋转的 div 的轴有问题。
现在钻石在边内旋转,我想从它的顶部中心旋转。
这是一个例子:http: //jsfiddle.net/DtQd8/
HTML
<div class="diamond">
<div class="diamondIn">
<div class="front"></div>
<div class="back"></div>
</div>
</div>
CSS
.diamond
{
height: 150px;
width: 150px;
-webkit-perspective: 1000;
-moz-perspective: 1000;
perspective: 1000;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
position: absolute;
}
.diamondIn
{
height: 150px;
width: 150px;
-webkit-transition: 0.6s;
-moz-transition: 0.6s;
transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
position: relative;
float: left;
}
.diamondIn:hover
{
-webkit-transform: rotate3d(0,1,0,180deg);
-moz-transform: rotate3d(0,1,0,180deg);
transform: rotate3d(0,1,0,180deg);
}
.diamondIn .front,
.diamondIn .back
{
top: 0;
left: 0;
height: 150px;
width: 150px;
background: #fff;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
}
.diamondIn .front
{
z-index: 2;
background: #00ff00;
}
.diamondIn .back
{
-webkit-transform: rotate3d(0,1,0,180deg);
-moz-transform: rotate3d(0,1,0,180deg);
transform: rotate3d(0,1,0,180deg);
background: #ff0000;
}
有人有什么主意吗?