CSS animation-direction属性

animation-direction属性

CSS中的animation-direction属性,可以定义@keyframes定义的动画是否需要轮流方向播放。


语法

animationo-direction:value

可选属性值

属性值描述
normal默认值,动画正常播放
alternate动画轮流方向播放

提示:alternate属性值会在动画播放的奇数次数正常播放,然后在偶数次数向后播放。


animation-direction实例代码,及在线编辑器

<div id='d1'></div>

<style>
@keyframes animationDirection{
0%   {background-color:skyblue; left:0px; top:0px;}
25%  {background-color:blue; left:250px; top:0px;}
50%  {background-color:orange; left:250px; top:250px;}
75%  {background-color:yellow; left:0px; top:250px;}
100% {background-color:pink; left:0px; top:0px;}
}


#d1{
width:80px;
height:80px;
background-color:skyblue;
position:relative;
animation:animationDirection 6s infinite;
animation-direction:alternate;
}
</style>

全栈前端 / CSS教程 :



























Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.