CSS3 animation-duration 属性
设置动画在两秒内完成:
<html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
div {
width: 100px;
height: 100px;
background: red;
position: relative;
animation: mymove infinite;
animation-duration: 2s;
/* Safari and Chrome */
-webkit-animation: mymove infinite;
-webkit-animation-duration: 2s;
}
@keyframes mymove {
from {
top: 0px;
}
to {
top: 200px;
}
}
@-webkit-keyframes mymove
/* Safari and Chrome */
{
from {
top: 0px;
}
to {
top: 200px;
}
}
</style>
</head>
<body>
<p><strong>注意:</strong> animation-duration属性不兼容 Internet Explorer 9 以及更早版本的浏览器.</p>
<div></div>
<p><b>注意:</b> 要指定动画属性。否则时间若是0,动画不会进行。</p>
</body>
</html>
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。
属性 | |||||
---|---|---|---|---|---|
animation-duration | 43.0 3.0 -webkit- |
10.0 | 16.0 5.0 -moz- |
9.0 4.0 -webkit- |
30.0 15.0 -webkit- 12.0 -o- |
标签定义及使用说明
animation-duration属性定义动画完成一个周期需要多少秒或毫秒。
默认值: | 0 |
---|---|
继承: | no |
版本: | CSS3 |
JavaScript 语法: | object object.style.animationDuration="3s" |
语法
animation-duration: time;
值 | 说明 |
---|---|
time | 指定动画播放完成花费的时间。默认值为 0,意味着没有动画效果。 |
相关文章
CSS3 教程: CSS3 动画