Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使CSS动画在完成后不反转?内例_Html_Css_Animation_Keyframe - Fatal编程技术网

Html 如何使CSS动画在完成后不反转?内例

Html 如何使CSS动画在完成后不反转?内例,html,css,animation,keyframe,Html,Css,Animation,Keyframe,我现在有一张图片正在使用关键帧进行旋转和缩放,但我的问题是每次迭代后它都会反转旋转方向。如何阻止这种情况发生,使旋转在一个方向上平滑。请参见此处的完整网页HTML: <html class="fourzerofour"> <head> <!-- Hey, look at you, you know how to view the source code, well done! Here's a unicode cookie: It has animation:

我现在有一张图片正在使用关键帧进行旋转和缩放,但我的问题是每次迭代后它都会反转旋转方向。如何阻止这种情况发生,使旋转在一个方向上平滑。请参见此处的完整网页HTML:

<html class="fourzerofour">
<head>
  <!-- Hey, look at you, you know how to view the source code, well done! Here's a unicode cookie: It has 
animation: rotating 3s linear infinite
, where
infinite
is the
transition-duration
and here
rotating
is the
transition
i.e. why it keeps repeating its
animation
, removing that will do the trick for you.

Here the JSFiddle.

Get rid of the
infinite
line and remove the 50% keyframe styles as well as this is the middle of the animation. Instead give the 100% the final animation styles you would like: JS Fiddle

Appending
infinite
on the animation will have it continually loop.

.rotating {
  -webkit-animation: rotating 3s linear;
  -moz-animation: rotating 3s linear;
  -ms-animation: rotating 3s linear;
  -o-animation: rotating 3s linear;
  animation: rotating 3s linear;
  animation-direction: alternate;
  width: 10em;

}

p.fourzerofour + .rotating:active {
      -webkit-filter: invert(1);

}

@-webkit-keyframes rotating /* Safari and Chrome */ {
  0% {
    -ms-transform: rotate(0deg) scale(.1);
    -moz-transform: rotate(0deg) scale(.1);
    -webkit-transform: rotate(0deg) scale(.1);
    -o-transform: rotate(0deg) scale(.1);
    transform: rotate(0deg) scale(.1);
  }
  100% {
    -ms-transform: rotate(360deg) scale(1);
    -moz-transform: rotate(360deg) scale(1);
    -webkit-transform: rotate(360deg) scale(1);
    -o-transform: rotate(360deg) scale(1);
    transform: rotate(360deg) scale(1):
  }

}

@keyframes rotating {
  0% {
    -ms-transform: rotate(0deg) scale(.1);
    -moz-transform: rotate(0deg) scale(.1);
    -webkit-transform: rotate(0deg) scale(.1);
    -o-transform: rotate(0deg) scale(.1);
    transform: rotate(0deg) scale(.1);
  }
  100% {
    -ms-transform: rotate(360deg) scale(1);
    -moz-transform: rotate(360deg) scale(1);
    -webkit-transform: rotate(360deg) sscale(1);
    -o-transform: rotate(360deg) scale(1);
    transform: rotate(360deg) scale(1);
  }

}


它有
动画:旋转3s线性无限
,其中
无限
过渡持续时间
,这里
旋转
过渡
,也就是说,为什么它不断重复它的
动画
,移除它会对你有好处


这里是。

摆脱
无限
行,删除50%的关键帧样式,这是动画的中间部分。取而代之的是,为用户提供100%您想要的最终动画样式:

在动画上附加
infinite
,将使其不断循环


如果我误解了所需的效果,而您希望它在一个方向上不断循环,请参阅@maioman answer

如果您删除
动画方向:alternate
则应该可以


此外,我在fiddle中调整了轮换

链接到外部资源是可以的,但是在这里包括完整的答案,包括解释。天哪,你做到了!我知道如何删除动画方向,但不确定,因为这不会使它保持循环,但您所做的旋转调整正是我所寻找的!我会记下来作为答案,但我不完全确定它为什么有效。。为什么添加720deg会使它工作?抱歉,CSS动画非常新。再次感谢@egrodo这是因为动画以720deg结束,从0开始;因为图像的位置在720deg和0 deg上是相同的,所以在720deg上重新启动动画会使trickOh,他们会吗?真奇怪。。所以他们从720/0开始,到720/0结束,明白了。这很有道理,我只是不明白为什么是720度而不是360度?谢谢谢谢你的时间,但是是的,@maioman创造了想要的效果+1.