- HTML中文网
- 联系QQ:88526
- QQ交流群

- 微信公众号

animation-direction属性
含义:
animation-direction 属性定义是否循环交替反向播放动画。
注意:如果动画被设置为只播放一次,该属性将不起作用
浏览器支持:
属性 | ![]() | ![]() | ![]() | ![]() | ![]() |
浏览器 | IE | Chrome | Firefox | Safari | Opera |
animation-direction | 10.0 | 43.0 4.0 -webkit- | 16.0/5.0 -moz- | 9.0/4.0 -webkit- | 30.0 15.0 -webkit- 12.0 -o- |
CSS语法:
animation-direction: normal|reverse|alternate|alternate-reverse|initial|inherit;
属性值
normal :默认值。动画按正常播放
reverse:动画反向播放
alternate :动画在奇数次(1、3、5...)正向播放,在偶数次(2、4、6...)反向播放
alternate-reverse:动画在奇数次(1、3、5...)反向播放,在偶数次(2、4、6...)正向播放
initial:设置该属性为它的默认值,请参考 initial
inherit:从父元素继承该属性,请参考 inherit
设置方块在奇数时正向播放,在偶数时反向播放
<style type="text/css"> div{ width:100px; height:100px; position: relative; background-color:hsl(120,65%,75%); animation:demo 5s alternate infinite; /*Safari 和 Chrome */ -webkit-animation:demo 5s infinite; animation-direction:alternate; /*Safari 和 Chrome */ -webkit-animation-direction:alternate; } @keyframes demo { from {left:0px;} to {left:450px;} } /*Safari 和 Chrome */ @-webkit-keyframes demo { from {left:0px;} to {left:450px;} } </style> </head> <body> <div></div> </body>
点击 "运行实例" 按钮查看在线实例
效果图:
推荐手册