【发布时间】:2016-12-25 12:43:45
【问题描述】:
我正在尝试让三个对象围绕一个圆圈旋转。到目前为止,我已经能够让一个物体绕着圆圈旋转。如果不弄乱代码,我将无法获得多个。任何人都可以就实现这一目标的最佳方法提出建议吗?这是代码的一部分和一个小提琴。谢谢!
这里是Demo
.outCircle {
width: 200px;
height: 200px;
background-color: lightblue;
left: 270px;
position: absolute;
top: 50px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
}
.rotate {
width: 100%;
height: 100%;
-webkit-animation: circle 10s infinite linear;
}
.counterrotate {
width: 50px;
height: 50px;
-webkit-animation: ccircle 10s infinite linear;
}
.inner {
width: 100px;
height: 100px;
background: red;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 100px;
position: absolute;
left: 0px;
top: 0px;
background-color: red;
display: block;
}
@-webkit-keyframes circle {
from {
-webkit-transform: rotateZ(0deg)
}
to {
-webkit-transform: rotateZ(360deg)
}
}
@-webkit-keyframes ccircle {
from {
-webkit-transform: rotateZ(360deg)
}
to {
-webkit-transform: rotateZ(0deg)
}
}
<div class="outCircle">
<div class="rotate">
<div class="counterrotate">
<div class="inner">hello
</div>
</div>
</div>
</div>
【问题讨论】:
-
你不需要javascript或jquery的标签,因为你的问题都没有提到。
-
Javascript 或 Jquery 在这里是最佳选择,因为计算可能会变得混乱 - stackoverflow.com/questions/10152390/…
标签: html css css-animations