我有一些使用CSS3在屏幕上不断移动div的代码,我想要做的是在第一个动画周期中启动我在CSS中在动画的不同点(即20%)编写的动画,从那时开始每个周期0%。感谢您的帮助,JSFiddle如下。
HTML:
<div class="x1">
</div>
CSS:
.x1 {
right: 30%;
top: 90px;
-webkit-animation: animato 15s linear infinite;
-moz-animation: animato 15s linear infinite;
-o-animation: animato 15s linear infinite;
animation: animato 15s linear infinite;
}
@keyframes animato {
0% { right: -25%; }
20% { right: 0%; }
40% { right: 25%; }
60% { right: 50%; }
80% { right: 75%; }
100% { right: 100%; }
}
如何以20%的分数开始animato
,比方说?
答案 0 :(得分:3)
.x1 {
right: 30%;
top: 90px;
-webkit-animation: animato 15s linear infinite;
-moz-animation: animato 15s linear infinite;
-o-animation: animato 15s linear infinite;
animation: animato 15s linear infinite;
-webkit-animation-delay: -3s; /* offsets the animation starting point for 3/15 = 20% */
-moz-animation-delay: -3s;
-o-animation-delay: -3s;
animation-delay: -3s;
}