1. 程式人生 > >關於動畫Animate.css的使用方法

關於動畫Animate.css的使用方法

一個 mov git som log clas spa 版權 dem

   首先貼個官網:

https://daneden.github.io/animate.css/
  1、引入animate css文件
1     <head>
2           <link rel="stylesheet" href="animate.min.css">
3     </head>

  2、給指定的元素加上指定的動畫樣式名

    <div class="animated bounceOutLeft"></div>

  

  這裏包括兩個class名,第一個是基本的,必須添加的樣式名,任何想實現的元素都得添加這個。第二個是

  指定的動畫樣式名。

  3、如果說想給某個元素動態添加動畫樣式,可以通過jquery來實現:

  

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

  4、當動畫效果執行完成後還可以通過以下代碼添加事件

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

  你也可以通過 JavaScript 或 jQuery 給元素添加這些 class,比如:

1     $(function(){
2         $(‘#jq22‘).addClass(‘animated bounce‘);
3     });

  有些動畫效果最後會讓元素不可見,比如淡出、向左滑動等等,可能你又需要將 class 刪除,比如:

1     $(function(){
2         $(‘#jq22‘).addClass(‘animated bounce‘);
3         setTimeout(function(){
4             $(‘#jq22‘).removeClass(‘bounce‘);
5         }, 1000);
6 });

  animate.css 的默認設置也許有些時候並不是我們想要的,所以你可以重新設置,比如:

1     #jq22{
2         animate-duration: 2s;    //動畫持續時間
3         animate-delay: 1s;    //動畫延遲時間
4         animate-iteration-count: 2;    //動畫執行次數
5     }

  所有的動畫樣式名請參見demo頁面。

  最後再貼個網站結尾,版權歸以下網站所有,作者:hacker

http://www.jq22.com/jquery-info819

關於動畫Animate.css的使用方法