• 技术文章 >web前端 >前端问答

    css animation-direction属性怎么用

    藏色散人藏色散人2019-05-29 09:15:14原创1608
    css animation-direction属性是用来定义是否应该轮流反向播放动画的;当动画播放次数超过一次时,我们就可以通过设置animation-direction的值为alternate来实现动画轮流反向播放。

    css animation-direction属性怎么用?

    animation-direction属性是用来定义是否应该轮流反向播放动画的;当动画播放次数超过一次时,我们就可以通过设置animation-direction的值为alternate来实现动画轮流反向播放。

    作用:定义是否应该轮流反向播放动画。

    语法:

    animation-direction: normal|alternate;

    说明:normal 默认值。动画应该正常播放。alternate 动画应该轮流反向播放。

    注释:如果把动画设置为只播放一次,则该属性没有效果。

    css animation-direction属性使用示例

    <!DOCTYPE html>
    <html>
    <head>
    <style> 
    div
    {
    width:100px;
    height:100px;
    background:red;
    position:relative;
    animation:myfirst 5s infinite;
    animation-direction:alternate;
    /* Safari and Chrome */
    -webkit-animation:myfirst 5s infinite;
    -webkit-animation-direction:alternate;
    }
    @keyframes myfirst
    {
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
    }
    @-webkit-keyframes myfirst /* Safari and Chrome */
    {
    0%   {background:red; left:0px; top:0px;}
    25%  {background:yellow; left:200px; top:0px;}
    50%  {background:blue; left:200px; top:200px;}
    75%  {background:green; left:0px; top:200px;}
    100% {background:red; left:0px; top:0px;}
    }
    </style>
    </head>
    <body>
    <p><strong>注释:</strong>Internet Explorer 9 以及更早的版本不支持 animation-direction 属性。</p>
    <div></div>
    </body>
    </html>

    效果输出:

    f5e1ca243adf2a77f58024fcdfed678.png

    以上就是css animation-direction属性怎么用的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:css animation-delay属性怎么用 下一篇:css animation-duration属性怎么用
    VIP课程(WEB全栈开发)

    相关文章推荐

    • 【活动】充值PHP中文网VIP即送云服务器• css word-wrap属性怎么用• css animation-fill-mode属性怎么用• css background属性怎么用• css animation-delay属性怎么用
    1/1

    PHP中文网