Animate.css的簡單使用


Animate.css的簡單使用

animate.css是一個基於css3 animation動畫庫,庫中預設了幾乎所有日常開發中的需求

animate.css 的官網為:https://animate.style 

一、安裝方式

CDN 地址:<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css"/>

animate.css地址:鏈接:https://pan.baidu.com/s/1wxEWXJ7cBydb9afJkYoGLw  提取碼:uphx

二、animate.css 4.x區別和使用方法

animate.css 4.x版本迎來了重大改變,不僅添加了更多動畫效果,引用前綴也進行了改變。

在3.x版本時,基本類 都是加animated ,在4.x版本 加 animate__animated,就是要加 animate__ 前綴。注意區別版本

<h1 class="animate__animated animate__pulse">An animated 4.x element</h1>
<h1 class="animated pulse">An animated 3.x element</h1>

三、animate.css 4.x的基本使用方法

安裝Animate.css之后,將該類animate__animated以及 動畫名稱 添加到元素中(不要忘記animate__前綴!)

動畫名稱就是Animate官網提供給我們的css類名,當我們鼠標移動到某個類名 可以點擊右邊的 直接復制類名稱   (此時案例復制的類名稱為  animate__bounce)

 

 

 注意,在使用動畫名稱時還要講基本類名稱animate__animated,一起添加,才能起作用。

右側的英文比較多,這里提供了一些主要的類名中午注釋

fade: {
        title: '淡入淡出',
        fadeIn: '淡入',
        fadeInDown: '向下淡入',
        fadeInDownBig: '向下快速淡入',
        fadeInLeft: '向右淡入',
        fadeInLeftBig: '向右快速淡入',
        fadeInRight: '向左淡入',
        fadeInRightBig: '向左快速淡入',
        fadeInUp: '向上淡入',
        fadeInUpBig: '向上快速淡入',
        fadeOut: '淡出',
        fadeOutDown: '向下淡出',
        fadeOutDownBig: '向下快速淡出',
        fadeOutLeft: '向左淡出',
        fadeOutLeftBig: '向左快速淡出',
        adeOutRight: '向右淡出',
        fadeOutRightBig: '向右快速淡出',
        fadeOutUp: '向上淡出',
        fadeOutUpBig: '向上快速淡出'
      },
      bounce: {
        title: '彈跳類',
        bounceIn: '彈跳進入',
        bounceInDown: '向下彈跳進入',
        bounceInLeft: '向右彈跳進入',
        bounceInRight: '向左彈跳進入',
        bounceInUp: '向上彈跳進入',
        bounceOut: '彈跳退出',
        bounceOutDown: '向下彈跳退出',
        bounceOutLeft: '向左彈跳退出',
        bounceOutRight: '向右彈跳退出',
        bounceOutUp: '向上彈跳退出'
      },
      zoom: {
        title: '縮放類',
        zoomIn: '放大進入',
        zoomInDown: '向下放大進入',
        zoomInLeft: '向右放大進入',
        zoomInRight: '向左放大進入',
        zoomInUp: '向上放大進入',
        zoomOut: '縮小退出',
        zoomOutDown: '向下縮小退出',
        zoomOutLeft: '向左縮小退出',
        zoomOutRight: '向右縮小退出',
        zoomOutUp: '向上縮小退出'
      },
      rotate: {
        title: '旋轉類',
        rotateIn: '順時針旋轉進入',
        rotateInDownLeft: '從左往下旋入',
        rotateInDownRight: '從右往下旋入',
        rotateInUpLeft: '從左往上旋入',
        rotateInUpRight: '從右往上旋入',
        rotateOut: '順時針旋轉退出',
        rotateOutDownLeft: '向左下旋出',
        rotateOutDownRight: '向右下旋出',
        rotateOutUpLeft: '向左上旋出',
        rotateOutUpRight: '向右上旋出'
      },
      flip: {
        title: '翻轉類',
        flipInX: '水平翻轉進入',
        flipInY: '垂直翻轉進入',
        flipOutX: '水平翻轉退出',
        flipOutY: '垂直翻轉退出'
      },
      strong: {
        title: '強調類',
        bounce: '彈跳',
        flash: '閃爍',
        pulse: '脈沖',
        rubberBand: '橡皮筋',
        shake: '左右弱晃動',
        swing: '上下擺動',
        tada: '縮放擺動',
        wobble: '左右強晃動',
        jello: '拉伸抖動'
      }	

 基本使用方法

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css"/>
         <style type="text/css">
             /* 對某個動畫名稱設置一個周期的時間,缺點就是這個只能對單一某個動畫進行設置 */
            .animate__pulse {
                  --animate-duration: 5s;
                  --animate-delay: 5.9s;
            }
            
            /* 將所有的動畫設置動畫時間*/
            :root {
              --animate-duration: 2000ms;                           
            }
            /*直接調用關鍵幀名稱*/
            p{            
                animation-name:jello ;
                animation-duration: 2s;
                animation-delay: 1.5s;
            }
         </style>
    </head>
    <body>
        <p>hgtftgfgjfjnghf</p>
        <h1 class="animate__animated animate__pulse">An animated 4.x element</h1>
        <h1 class="animate__animated animate__heartBeat">An animated 4.x element</h1>
        <h1 class="animate__animated animate__jello">An animated 4.x element</h1>
        
    </body>
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM