標籤: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動畫像喝水一樣容易