前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >animation-duration 属性——动画示例

animation-duration 属性——动画示例

作者头像
Html5知典
发布2019-11-26 17:08:17
5020
发布2019-11-26 17:08:17
举报
文章被收录于专栏:Html5知典Html5知典

用途

animation-duration 规定动画完成一个周期所花费的秒或毫秒。默认是 0。

语法

代码语言:javascript
复制
animation-duration:2s;
animation-duration:2ms;

描述

<time>

动画样式应用到元素到元素开始执行动画的时间差。该值可用单位为秒(m)和毫秒(ms)。默认值为0s,表示无动画。

例子

代码语言:javascript
复制
/* HTML */
<div class="stage"> 
    <figure class="ball"></figure> 
</div>
    
/* CSS */
@keyframes 'slide' { 
    from { 
        left: 0; 
        top: 0; } 
    50% { 
        left: 244px; 
        top: 100px; } 
    to { 
        left: 488px; 
        top: 0; } 
} 
.stage { 
    background: #ccc; 
    border-radius: 6px; 
    height: 150px; 
    position: relative; 
    min-width: 550px; 
} 
.stage .ball { 
    animation-name: slide; 
    animation-duration:2s; 
    animation-timing-function: ease-in-out; 
    animation-delay: 1.5s;//延迟1.5秒 
    animation-iteration-count: infinite; 
    animation-direction: alternate;//反向运行动画,每周期结束动画由尾到头运行。 } 
.ball { 
    background: red; 
    border-radius: 50%; 
    height: 40px; 
    position:
     absolute; 
     width: 40px; }

执行结果

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-11-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Html5知典 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档