案例:CSS3 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style> 
5
div
6
{
7
width:100px;
8
height:100px;
9
background:red;
10
position:relative;
11
animation:myfirst 5s infinite;
12
animation-direction:alternate;
13
14
/* Safari and Chrome */
15
-webkit-animation:myfirst 5s infinite;
16
-webkit-animation-direction:alternate;
17
}
18
19
@keyframes myfirst
20
{
21
0%   {background:red; left:0px; top:0px;}
22
25%  {background:yellow; left:200px; top:0px;}
23
50%  {background:blue; left:200px; top:200px;}
24
75%  {background:green; left:0px; top:200px;}
25
100% {background:red; left:0px; top:0px;}
26
}
27
28
@-webkit-keyframes myfirst /* Safari and Chrome */
29
{
30
0%   {background:red; left:0px; top:0px;}
31
25%  {background:yellow; left:200px; top:0px;}
32
50%  {background:blue; left:200px; top:200px;}
33
75%  {background:green; left:0px; top:200px;}
34
100% {background:red; left:0px; top:0px;}
35
}
36
</style>
37
</head>
38
<body>
39
40
<p><strong>注释:</strong>Internet Explorer 9 以及更早的版本不支持 animation-direction 属性。</p>
41
42
<div></div>
43
44
</body>
45
</html>
46