CSS3動畫效果animation

來源:互聯網
上載者:User

標籤:inf   strong   doctype   scale   doc   form   exp   元素   支援   

利用CSS中animation為元素添加動畫,代碼格式為:

animation:動畫名 .75s infinite;
-webkit-animation:動畫名 .75s infinite; /*Safari and Chrome*/

第二句是為了相容Google瀏覽器等,在指定動畫時需要將元素指定為相對定位:position:relative;

接著為動畫指定效果:

@keyframes 動畫名
{
from {transform: none;}
to {transform: scale(1.6);}
}

@-webkit-keyframes 動畫名
{
from {-webkit-transform: none;}
to {-webkit-transform: scale(1.6);}
}

 

 

完整例子:

效果連結:http://www.w3school.com.cn/tiy/t.asp?f=css3_animation

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

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

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

<p><strong>注釋:</strong>Internet Explorer 9 以及更早的版本不支援 animation 屬性。</p>

<div></div>

</body>
</html>

CSS3動畫效果animation

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.