0
HTMLCSS旋转变换对象
<div class="camera">
<div class="dreid">
<div class="planet1"></div>
<div class="planet2"></div>
</div>
</div>
CSS
.camera {
width: 300px;
height: 300px;
border: 1px solid black;
-webkit-perspective: 800;
-webkit-perspective-origin: 50% 700px;
}
.dreid {
width:220px;
height:220px;
border-radius: 50%;
border: 1px solid black;
margin: 60px auto;
-webkit-transform: rotateX(45deg);
-webkit-animation-name: spin;
-webkit-animation-duration: 10s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
@-webkit-keyframes spin {
from {
-webkit-transform:rotate(0deg);
}
to {
-webkit-transform:rotate(360deg);
}
}
.planet1 {
position:absolute;
top:0;
left:0;
width:50px;
height:50px;
background:red;
border-radius:50%;
}
.planet2 {
position: absolute;
top:170px;
left:170px;
width:50px;
height:50px;
background:red;
border-radius:50%;
}
,你可以看到我试着旋转它之前应用的角度来圆(有点像在行星系统)。问题是,动画位似乎覆盖了我用-perspective和-transform:rotate设置的转换位。是否有可能用纯CSS完成它?
编辑:JSFiddle
在一个侧面说明,如果你想 –
我尝试添加-transform你可以使用伪元素,而不是内部元素:rotateX我的“旋转”功能,但导致透视覆盖纺纱。不知道我是否理解正确。 – poochy
啊回答太快了。是的,这就是我的意思!但我很愚蠢,以至于删除我在容器中的-transform并将它添加到我的动画中。非常感谢你! – poochy