CSS3之animation

瀏覽器支持:css

Internet Explorer 十、Firefox 以及 Opera 支持 animation 屬性。html

Safari 和 Chrome 支持替代的 -webkit-animation 屬性。web

註釋:Internet Explorer 9 以及更早的版本不支持 animation 屬性。瀏覽器

 

示例:動畫

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s infinite;
-moz-animation:mymove 5s infinite; /* Firefox */
-webkit-animation:mymove 5s infinite; /* Safari and Chrome */
-o-animation:mymove 5s infinite; /* Opera */
}

@keyframes mymove
{
from {top:0px;}
to {top:200px;}
}

@-moz-keyframes mymove /* Firefox */
{
from {top:0px;}
to {top:200px;}
}

@-webkit-keyframes mymove /* Safari and Chrome */
{
from {top:0px;}
to {top:200px;}
}

@-o-keyframes mymove /* Opera */
{
from {top:0px;}
to {top:200px;}
}
</style>
</head>
<body>

<p><b>註釋:</b>本例在 Internet Explorer 中無效。</p>

<div></div>

</body>
</html>

 

語法:spa

animation: name duration timing-function delay iteration-count direction;
 
描述
animation-name 規定須要綁定到選擇器的 keyframe 名稱。
animation-duration

規定完成動畫所花費的時間,以秒或毫秒計。ssr

(注:默認時長爲 0,不會播放動畫了)code

animation-timing-function 規定動畫的速度曲線。
animation-delay 規定在動畫開始以前的延遲。
animation-iteration-count 規定動畫應該播放的次數。
animation-direction 規定是否應該輪流反向播放動畫。
相關文章
相關標籤/搜索