zoukankan      html  css  js  c++  java
  • 好用的css3类库---1、css3动画库:animate.css

    好用的css3类库---1、css3动画库:animate.css

    一、总结

    一句话总结:

    animate.css一款强大的预设css3动画库,并且使用及其简单:引入animate.css,然后直接在标签上面使用样式即可

    1、animate.css如何使用?

    引入animate.css,然后直接在标签上面使用样式即可:例如<div class="box animated flash"></div>
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Document</title>
      <link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
      <style>
        .box{height: 100px;width: 100px;background-color: lightblue}
      </style>
    </head>
    <body>
      <div class="box animated flash"></div>
    </body>
    </html>

    二、animate.css的使用

    转自或参考:animate.css的使用
    https://www.cnblogs.com/apolloren/p/10828166.html

    animate.css演示站

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

    animate.css的github位置及文档

    https://github.com/daneden/animate.css/

    前面的话

      animate.css是一个使用CSS3的animation制作的动画效果的CSS集合,里面预设了很多种常用的动画,且使用非常简单。本文将详细介绍animate.css的使用

    引入

      animate.css的最新版本是3.5.2,引入animate.css很容易,有以下几种方法

      1、从官网下载

      https://raw.github.com/daneden/animate.css/master/animate.css

      2、通过npm安装

    $ npm install animate.css

      3、使用在线cdn

    https://unpkg.com/animate.css@3.5.2/animate.min.css

    效果演示

      animate.css的使用非常简单,因为它是把不同的动画绑定到了不同的类里,所以想要使用哪种动画,只需要把通用类animated和相应的类添加到元素上就行了

      下面来详细介绍animate.css里面的类,主要包括Attention(晃动效果)、bounce(弹性缓冲效果)、fade(透明度变化效果)、flip(翻转效果)、rotate(旋转效果)、slide(滑动效果)、zoom(变焦效果)、special(特殊效果)这8类

    【Attention(晃动效果)】

    bounce
    flash
    pulse
    rubberBand
    shake
    headShake
    swing
    tada
    wobble
    jello

      以在div上使用bounce为例

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

    【bounce(弹性缓冲效果)】

    bounceIn
    bounceInDown
    bounceInLeft
    bounceInRight
    bounceInUp
    bounceOut
    bounceOutDown
    bounceOutLeft
    bounceOutRight
    bounceOutUp

    【fade(透明度变化效果)】

    fadeIn
    fadeInDown
    fadeInDownBig
    fadeInLeft
    fadeInLeftBig
    fadeInRight
    fadeInRightBig
    fadeInUp
    fadeInUpBig
    fadeOut
    fadeOutDown
    fadeOutDownBig
    fadeOutLeft
    fadeOutLeftBig
    fadeOutRight
    fadeOutRightBig
    fadeOutUp
    fadeOutUpBig

    【flip(翻转效果)】

    flip
    flipInX
    flipInY
    flipOutX
    flipOutY

    【rotate(旋转效果)】

    rotateIn
    rotateInDownLeft
    rotateInDownRight
    rotateInUpLeft
    rotateInUpRight
    rotateOut
    rotateOutDownLeft
    rotateOutDownRight
    rotateOutUpLeft
    rotateOutUpRight

    【slide(滑动效果)】

    slideInDown
    slideInLeft
    slideInRight
    slideInUp
    slideOutDown
    slideOutLeft
    slideOutRight
    slideOutUp

    【zoom(变焦效果)】

    zoomIn
    zoomInDown
    zoomInLeft
    zoomInRight
    zoomInUp
    zoomOut
    zoomOutDown
    zoomOutLeft
    zoomOutRight
    zoomOutUp

    【special(特殊效果)】 

    hinge
    rollIn
    rollOut
    lightSpeedIn
    lightSpeedOut

    实际应用

      在一般的使用中,直接在元素上添加animated和对应的类名即可

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
    <style>
    .box{height: 100px; 100px;background-color: lightblue}
    </style>
    </head>
    <body>
    <div class="box animated flash"></div>
    </body>
    </html>

      通过给JS添加或删除class,可以实现动态效果

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
    <style>
    .box{height: 100px; 100px;background-color: lightblue}
    </style>
    </head>
    <body>
    <button id="btn1">添加</button>
    <button id="btn2">移除</button>
    <div id="box" class="box"></div>
    <script>
    var oBtn1 = document.getElementById('btn1');
    var oBtn2 = document.getElementById('btn2');
    var oBox = document.getElementById('box');
    oBtn1.onclick = function(){
      oBox.classList.add('animated');
      oBox.classList.add('flash');
    }
    oBtn2.onclick = function(){
      oBox.classList.remove('flash');
    }
    </script>
    </body>
    </html>

      至于动画的配置参数,比如动画持续时间,动画的执行次数等等,可以在元素上自行定义,覆盖掉animate.css里面所定义的就行了

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
    <style>
    .box{height: 100px; 100px;background-color: lightblue}
    .infinite{animation-iteration-count:infinite;}
    </style>
    </head>
    <body>
    <button id="btn1">添加循环的动画效果</button>
    <button id="btn2">移除</button>
    <div id="box" class="box"></div>
    <script>
    var oBtn1 = document.getElementById('btn1');
    var oBtn2 = document.getElementById('btn2');
    var oBox = document.getElementById('box');
    oBtn1.onclick = function(){
      oBox.classList.add('animated');
      oBox.classList.add('flash');
      oBox.classList.add('infinite');
    }
    oBtn2.onclick = function(){
      oBox.classList.remove('flash');
    }
    </script>
    </body>
    </html>

    三、课程代码

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>css3动画库:animate.css</title>
     6     <link rel="stylesheet" href="animate.css">
     7     <style>
     8         .box1{
     9             width: 200px;
    10             height: 200px;
    11             background-color: orange;
    12         }
    13     </style>
    14 </head>
    15 <body>
    16 <!--    <div class="box1 animated flash infinite delay-2s">-->
    17 
    18 <!--    </div>-->
    19 <div id="box1" class="box1">
    20 
    21 </div>
    22 <button id="btn1">增加动画效果</button>
    23 <button id="btn2">移除动画效果</button>
    24 <script>
    25     let box1=document.getElementById('box1');
    26     let btn1=document.getElementById('btn1');
    27     let btn2=document.getElementById('btn2');
    28     btn1.onclick=function () {
    29         box1.classList.add('animated','slideInRight','infinite','faster');
    30     };
    31     btn2.onclick=function () {
    32         box1.classList.remove('animated');
    33     }
    34 </script>
    35 </body>
    36 </html>
     
  • 相关阅读:
    最全的曲文检测整理
    论文速读(Chuhui Xue——【arxiv2019】MSR_Multi-Scale Shape Regression for Scene Text Detection)
    论文速读(Jiaming Liu——【2019】Detecting Text in the Wild with Deep Character Embedding Network )
    论文速读(Yongchao Xu——【2018】TextField_Learning A Deep Direction Field for Irregular Scene Text)
    【论文速读】Yuliang Liu_2017_Detecting Curve Text in the Wild_New Dataset and New Solution
    【论文速读】XiangBai_CVPR2018_Rotation-Sensitive Regression for Oriented Scene Text Detection
    【论文速读】XiangBai_TIP2018_TextBoxes++_A Single-Shot Oriented Scene Text Detector
    【论文速读】Shitala Prasad_ECCV2018】Using Object Information for Spotting Text
    【论文速读】Sheng Zhang_AAAI2018_Feature Enhancement Network_A Refined Scene Text Detector
    【论文速读】Shangbang Long_ECCV2018_TextSnake_A Flexible Representation for Detecting Text of Arbitrary Shapes
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/12177708.html
Copyright © 2011-2022 走看看