Animate.css讓添加CSS動畫像喝水一樣容易

來源:互聯網
上載者:User

標籤:css3 animate

animate.css是一堆很酷的,有趣的,跨瀏覽器的動畫效果庫,你可以隨意在你的項目中使用。用在你想要突出的任何地方,如首頁,滑塊,這像喝水一樣容易,迷死人了。

用法

在您的網站上使用animate.css,只要簡單地把樣式表插入到文檔中的<HEAD>中,並為需要動畫的元素添加一個CSS類名即可,以及動畫的名稱。就是這樣!你就有了一個CSS動畫效果。超強!

<head>  <link rel="stylesheet" href="animate.min.css"></head>

注* 樣本

<h1 class="animated bounceOut">Animate.css</h1>

當與jQuery結合起來,你可以自己決定何時啟用這些動畫,通過jQuery動態添加使用動畫,你可以做的事情更多:

$(‘#yourElement‘).addClass(‘animated bounceOutLeft‘);

你還可以檢測動畫結束事件:

$(‘#yourElement‘).one(‘webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend‘, doSomething);

註:jQuery.one() 最多執行事件處理一次。點擊 此處 瞭解詳情。

您可以更改動畫的期間,增加延遲或改變顯示次數:

#yourElement {  -vendor-animation-duration: 3s;  -vendor-animation-delay: 2s;  -vendor-animation-iteration-count: infinite;}

注意:一定要在CSS恬當的的首碼(webkit, moz等)代替“vendor”

自訂Build(構建)

Animate.css支援Grunt,您可以很容易地建立自訂Build流程。首先,你需要Grunt和其他依賴關係:

$ cd path/to/animate.css/$ sudo npm install

接下來,運行grunt watch以更改和編譯您的自訂組建檔案。例如你只需要一部分動畫效果,只需編輯 animate-config.json 檔案,並選擇你需要使用的動畫。

"attention_seekers": {  "bounce": true,  "flash": false,  "pulse": false,  "shake": true,  "swing": true,  "tada": true,  "wobble": true}

官網地址: http://daneden.github.io/animate.css/


本文出自 “劉博方的部落格” 部落格,請務必保留此出處http://liubofang.blog.51cto.com/11162557/1854060

Animate.css讓添加CSS動畫像喝水一樣容易

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.