Animate.css(一款有意思的CSS3動畫庫)

官網:https://daneden.github.io/animate.css/css

animate.css 是一款跨瀏覽器的動畫庫。git

使用方式:github

  1. 在頁面的 <head>中引入樣式文件:web

    <head>
    <link rel="stylesheet" href="animate.min.css">
    </head>
  2. 給你想要添加動畫效果的元素加上 animated 樣式,若是想要動畫循環執行的話,你須要加上 infinite 樣式。瀏覽器

  3. 具體樣式在官網一一列舉出來啦,並且能夠直接查看效果,很炫酷啊!

例子:動畫

<h1 class="animated infinite bounce">Example</h1>

當你將 animate.css 與 jQuery 一塊兒使用或者添加你本身的 CSS 規則時, 你能夠用 animate.css 作一大堆其餘的事,使用 jQuery 動態添加動畫:spa

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

你也能夠檢測一個動畫是否結束了:code

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

注意: jQuery.one() 用在你但願只執行事件一次 的時候。blog

你能夠改變更畫的持續時間,添加延遲或改變它執行的次數:token

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

注意:確保用供應商的前綴(webkit, moz, 等等)來替換上面CSS中的 vendor

相關文章
相關標籤/搜索