animation-direction属性是用来定义是否应该轮流反向播放动画的;当动画播放次数超过一次时,我们就可以通过设置animation-direction的值为alternate来实现动画轮流反向播放。

CSS3 animation-direction属性
作用:定义是否应该轮流反向播放动画。
语法:
animation-direction: normal|alternate;
normal:默认值。动画应该正常播放。
alternate:动画应该轮流反向播放。
说明: 如果 animation-direction 值是 “alternate”,则动画会在奇数次数(1、3、5 等等)正常播放,而在偶数次数(2、4、6 等等)向后播放。
注:如果把动画设置为只播放一次,则该属性没有效果。
CSS3 animation-direction属性的使用示例
div{width:100px;height:100px;background:red;position:relative;animation:myfirst 5s infinite;animation-direction:alternate;/* Safari and Chrome */-webkit-animation:myfirst 5s infinite;-webkit-animation-direction:alternate;}@keyframes myfirst{0% {background:red; left:0px; top:0px;}25% {background:yellow; left:200px; top:0px;}50% {background:blue; left:200px; top:200px;}75% {background:green; left:0px; top:200px;}100% {background:red; left:0px; top:0px;}}@-webkit-keyframes myfirst /* Safari and Chrome */{0% {background:red; left:0px; top:0px;}25% {background:yellow; left:200px; top:0px;}50% {background:blue; left:200px; top:200px;}75% {background:green; left:0px; top:200px;}100% {background:red; left:0px; top:0px;}}
效果图:

以上就是本篇文章的全部内容,希望能对大家的学习有所帮助。更多精彩内容大家可以关注创想鸟相关教程栏目!!!
以上就是animation-direction属性怎么用的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1614072.html
微信扫一扫
支付宝扫一扫