天窗的蚂蚁
2016-01-09 20:50
animation-direction的属性中,alternate,他的作用是,动画播放在第偶数次向前播放,第奇数次向反方向播放。这句话说反了吧?应该是”播放次数是奇数时,动画向原方向播放;播放次数是偶数时,动画向反方向播放“大家觉得呢
用脑壳想一想大家都知道是错的,毕竟第一次它就是正向的,第二次才是反向的,明显写错了而已。
这里的奇数次不妨理解为奇数遍,就是播放第135遍的时候正方向
<--这段代码你运行一下,看到效果你就理解了!-->
<!DOCTYPE html>
<html>
<head>
<style>
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;}
}
</style>
</head>
<body>
<p><strong>注释:</strong>Internet Explorer 9 以及更早的版本不支持 animation-direction 属性。</p>
<div></div>
</body>
</html>
normal 每次循环都向正方向播放(默认值)
reverse 每次循环都向反方向播放
alternate 播放次数是奇数时,动画向原方向播放;播放次数是偶数时,动画向反方向播放
这是我从别处看到的。
十天精通CSS3
243146 学习 · 2677 问题
相似问题