位置:电子教程 > CSS3教程 (如果看不到内容请使用360浏览器) 推荐学习资源
CSS3基础样式
CSS3 高级样式
当前阅读教程:CSS3教程 > animation-duration 属性
阅读(22555525)      收藏       赞(5685)      分享
上一篇: animation-name 属性 下一篇: animation-timing-function 属性

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

紧跟在 -webkit-, -ms- -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。

image.png

标签定义及使用说明

animation-duration属性定义动画完成一个周期需要多少秒或毫秒。

默认值:

0

继承:

no

版本:

CSS3

JavaScript 语法:

object   object.style.animationDuration="3s"

语法

animation-duration: time;


 

说明

time

指定动画播放完成花费的时间。默认值为 0,意味着没有动画效果。

 

实例

设置动画在5秒内完成

代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>animation-duration 属性</title>
<!--定义内部样式-->
<style>
     div
     {
             width:100px;
             height:100px;
             background:red;
             position:relative;
             animation:mymove infinite;
             animation-duration:5s;/*设置动画在两秒内完成*/
 
             /* 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>

效果图

小白教程网www.2d5.net

image.png


上一篇: animation-name 属性 下一篇: animation-timing-function 属性
计算机毕业设计作品网      毕业设计文档网      小程序教程网       毕业设计资料网  |         毕业设计定制QQ:45157718(微信同号)(备注:毕设)