當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。