当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


CSS animation-play-state用法及代码示例


animation-play-state属性用于指定动画是运行还是暂停。

用法:

animation-play-state:paused|running|initial|inherit;

属性值:animation-play-state属性如下所示:


  • 已暂停:此属性用于指定动画已暂停。
  • 运行:它是默认值。此属性用于指定动画正在运行。
  • 初始:此属性用于设置其默认值。
  • 继承:它用于从其父级继承animation属性。

例:

<!DOCTYPE html>  
<html>  
    <head>  
        <title> 
            CSS | animation-play-state Property 
        </title> 
        <style>  
            body { 
                text-align:center; 
                width:70%; 
            } 
            h1 { 
                color:green; 
            } 
            .gfg { 
                width:50px; 
                height:50px; 
                background:green; 
                position:relative; 
                -webkit-animation:mymove 10s; 
                -webkit-animation-play-state:play; 
                animation:mymove 5s; 
                animation-play-state:play; 
            } 
            .geeks { 
                width:50px; 
                height:50px; 
                background:green; 
                position:relative; 
                -webkit-animation:mymove 10s; 
                -webkit-animation-play-state:paused; 
                animation:mymove 5s; 
                animation-play-state:paused; 
            } 
            @-webkit-keyframes mymove { 
                from { 
                    left:0%; 
                } 
                to { 
                    left:80%; 
                } 
            } 
                  
            @keyframes mymove { 
                from { 
                    left:0%; 
                } 
                to { 
                    left:80%; 
                } 
            } 
        </style>  
    </head>  
    <body>  
        <h1>GeeksforGeeks</h1>  
        <h2>animation-play-state property</h2>  
        <div class = "gfg"></div><br>  
        <div class = "geeks"></div>  
    </body>  
</html>                                                  

输出:

支持的浏览器:下面列出了animation-play-state属性支持的浏览器:

  • 谷歌浏览器43.0
  • Internet Explorer 10.0
  • Firefox 16.0
  • Opera 30.0
  • Safari 9.0


相关用法


注:本文由纯净天空筛选整理自vt_m大神的英文原创作品 CSS | animation-play-state Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。