亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

CSS3動畫

CSS3 動畫

CSS3 動畫

CSS3,我們可以創(chuàng)造動畫,它可以取代許多網頁動畫圖像,Flash動畫,和JAVAScripts。

CSS3 @keyframes 規(guī)則

要創(chuàng)建CSS3動畫,你將不得不了解@keyframes規(guī)則。

@keyframes規(guī)則是創(chuàng)建動畫。 @keyframes規(guī)則內指定一個CSS樣式和動畫將逐步從目前的樣式變更為新的樣式。


CSS3 動畫

當在 @keyframes 建立動畫,把它綁定到一個選擇器,否則動畫不會有任何效果。

指定至少這兩個CSS3的動畫屬性綁定定向一個選擇器:

規(guī)定動畫的名稱

規(guī)定動畫的時長

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">  
<style> 
div
{
width:100px;
height:100px;
background:red;
animation:myfirst 5s;
-webkit-animation:myfirst 5s; /* Safari and Chrome */
}
@keyframes myfirst
{
from {background:red;}
to {background:yellow;}
}


CSS3的動畫屬性

下面的表格列出了@keyframes 規(guī)則和所有動畫屬性:

屬性? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? 規(guī)定動畫。 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 中中使用 3

animation-name 規(guī)定 @keyframes 動畫的名稱。 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3

animation-duration 上完成一個週期中所花費的秒數或毫秒為單位。預設是 0。3

animation-timing-function 規(guī)定動畫的速度曲線。預設是 "ease"。 3

animation-delay 規(guī)定動畫何時開始。預設是 0。 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3中上的中播放次數。? 3

animation-iteration-count。預設是 1。 ? ? ? ? ? ? ? ? ?3

animation-direction 規(guī)定動畫是否在下一週期反向播放。預設是 "normal"。 3

animation-play-state 規(guī)定動畫是否正在運作或暫停。預設是 "running"。 ? 3

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style> 
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:myfirst 5s linear 2s infinite alternate;
/* Firefox: */
-moz-animation:myfirst 5s linear 2s infinite alternate;
/* Safari and Chrome: */
-webkit-animation:myfirst 5s linear 2s infinite alternate;
/* Opera: */
-o-animation:myfirst 5s linear 2s infinite 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;}
}
@-moz-keyframes myfirst /* Firefox */
{
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;}
}
@-o-keyframes myfirst /* Opera */
{
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><b>注意:</b> 該實例在 Internet Explorer 9 及更早 IE 版本是無效的。</p>
<div></div>
</body>
</html>
@-webkit-keyframes myfirst /* Safari and Chrome */
{
from {background:red;}
to {background:yellow;}
}
</style>
</head>
<body>
<p><b>注意:</b> 該實例在 Internet Explorer 9 及更早 IE 版本是無效的。</p>
<div></div>
</body>
</html>

CSS3動畫是什麼?


動畫是使元素從一種樣式逐漸改變?yōu)榱硪环N樣式的效果。

您可以改變任意多的樣式任意多的次數。

請用百分比來規(guī)定變化發(fā)生的時間,或用關鍵字 "from" 和 "to",等同於 0% 和 100%。

0% 是動畫的開始,100% 是動畫的完成。

為了得到最佳的瀏覽器支持,您應該始終定義 0% 和 100% 選擇器。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">  
<style> 
div
{
width:100px;
height:100px;
background:red;
animation:myfirst 5s;
-moz-animation:myfirst 5s; /* Firefox */
-webkit-animation:myfirst 5s; /* Safari and Chrome */
-o-animation:myfirst 5s; /* Opera */
}
@keyframes myfirst
{
0%   {background:red;}
25%  {background:yellow;}
50%  {background:blue;}
100% {background:green;}
}
@-moz-keyframes myfirst /* Firefox */
{
0%   {background:red;}
25%  {background:yellow;}
50%  {background:blue;}
100% {background:green;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
0%   {background:red;}
25%  {background:yellow;}
50%  {background:blue;}
100% {background:green;}
}
@-o-keyframes myfirst /* Opera */
{
0%   {background:red;}
25%  {background:yellow;}
50%  {background:blue;}
100% {background:green;}
}
</style>
</head>
<body>
<div></div>
<p><b>注釋:</b>當動畫完成時,會變回初始的樣式。</p>
<p><b>注意:</b> 該實例在 Internet Explorer 9 及更早 IE 版本是無效的。</p>
</body>
</html>

#

繼續(xù)學習
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> div { width:100px; height:100px; background:red; animation:myfirst 5s; -moz-animation:myfirst 5s; /* Firefox */ -webkit-animation:myfirst 5s; /* Safari and Chrome */ -o-animation:myfirst 5s; /* Opera */ } @keyframes myfirst { 0% {background:red;} 25% {background:yellow;} 50% {background:blue;} 100% {background:green;} } @-moz-keyframes myfirst /* Firefox */ { 0% {background:red;} 25% {background:yellow;} 50% {background:blue;} 100% {background:green;} } @-webkit-keyframes myfirst /* Safari and Chrome */ { 0% {background:red;} 25% {background:yellow;} 50% {background:blue;} 100% {background:green;} } @-o-keyframes myfirst /* Opera */ { 0% {background:red;} 25% {background:yellow;} 50% {background:blue;} 100% {background:green;} } </style> </head> <body> <div></div> <p><b>注釋:</b>當動畫完成時,會變回初始的樣式。</p> <p><b>注意:</b> 該實例在 Internet Explorer 9 及更早 IE 版本是無效的。</p> </body> </html>