首頁  >  文章  >  web前端  >  animation-play-state屬性怎麼用

animation-play-state屬性怎麼用

青灯夜游
青灯夜游原創
2019-02-01 11:12:114409瀏覽

animation-play-state屬性是用來指定動畫是否正在運作或已暫停;可以透過和JavaScript一起使用,實現在播放過程中暫停動畫的效果。

animation-play-state屬性怎麼用

CSS3  animation-play-state屬性

作用:animation- play-state 屬性規定動畫正在運作還是暫停。

語法:

animation-play-state: paused|running;

paused:規定動畫已暫停。

running:規定動畫正在播放。

說明:您可以在 JavaScript 中使用該屬性,這樣就能在播放過程中暫停動畫。

附註:Internet Explorer 9 以及更早的版本不支援 animation-play-state 屬性。

CSS3  animation-play-state屬性的使用範例

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s;
animation-play-state:running;

/* Safari and Chrome */
-webkit-animation:mymove 5s;
-webkit-animation-play-state:running;
}
div:hover{
animation-play-state:paused;
-webkit-animation-play-state:paused;
}
@keyframes mymove
{
from {left:0px;}
to {left:200px;}
}

@-webkit-keyframes mymove /* Safari and Chrome */
{
from {left:0px;}
to {left:200px;}
}
</style>
</head>
<body>

<div></div>

</body>
</html>

效果圖:

animation-play-state屬性怎麼用

以上就是這篇文章的全部內容,希望能對大家的學習有所幫助。更多精彩內容大家可以追蹤php中文網相關教學欄位! ! !

以上是animation-play-state屬性怎麼用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn