动画名称
动画的持续时间
属性 | 说明 |
@keyframes | 它用于指定动画。 |
animation | 这是一个简写属性,用于设置除animation-play-state和animation-fill-mode属性之外的所有属性。 |
animation-delay | 它指定动画何时开始。 |
animation-direction | 它指定动画是否应在备用周期中保留播放。 |
animation-duration | 它指定动画完成一个周期所花费的时间。 |
animation-fill-mode | 它指定元素的静态样式。 (当动画不播放时) |
animation-iteration-count | 它指定动画播放的次数。 |
animation-play-state | 它指定动画是正在运行还是暂停。 |
animation-name | 它指定@keyframes动画的名称。 |
animation-timing-function | 它指定动画的速度曲线。 |
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background: red;
-webkit-animation: myfirst 6s; /* Chrome, Safari, Opera */
animation: myfirst 5s;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes myfirst {
from {background: red;}
to {background: green;}
}
/* Standard syntax */
@keyframes myfirst {
from {background: red;}
to {background: green;}
}
</style>
</head>
<body>
<p><b>Note:</b> The IE 9 and earlier versions don't support CSS3 animation property. </p>
<div></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background: red;
position: relative;
-webkit-animation: myfirst 5s; /* Chrome, Safari, Opera */
animation: myfirst 5s;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes myfirst {
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:300px; top:0px;}
50% {background:blue; left:200px; top:300px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
/* Standard syntax */
@keyframes myfirst {
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:300px; top:0px;}
50% {background:blue; left:300px; top:200px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
</style>
</head>
<body>
<p><b>Note:</b> The Internet Explorer 9 and its earlier versions don't support this example.</p>
<div></div>
</body>
</html>