一、基本用法

引入CSS依赖

在元素的Class中加以下内容

animated (必选)

infinite (可选) 无限重复

bounce (必选) 动画样式 参考下方表格

delay-2s (可选) 延迟出现

Example

Class Name

bounce

flash

pulse

rubberBand

shake

headShake

swing

tada

wobble

jello

bounceIn

bounceInDown

bounceInLeft

bounceInRight

bounceInUp

bounceOut

bounceOutDown

bounceOutLeft

bounceOutRight

bounceOutUp

fadeIn

fadeInDown

fadeInDownBig

fadeInLeft

fadeInLeftBig

fadeInRight

fadeInRightBig

fadeInUp

fadeInUpBig

fadeOut

fadeOutDown

fadeOutDownBig

fadeOutLeft

fadeOutLeftBig

fadeOutRight

fadeOutRightBig

fadeOutUp

fadeOutUpBig

flipInX

flipInY

flipOutX

flipOutY

lightSpeedIn

lightSpeedOut

rotateIn

rotateInDownLeft

rotateInDownRight

rotateInUpLeft

rotateInUpRight

rotateOut

rotateOutDownLeft

rotateOutDownRight

rotateOutUpLeft

rotateOutUpRight

hinge

jackInTheBox

rollIn

rollOut

zoomIn

zoomInDown

zoomInLeft

zoomInRight

zoomInUp

zoomOut

zoomOutDown

zoomOutLeft

zoomOutRight

zoomOutUp

slideInDown

slideInLeft

slideInRight

slideInUp

slideOutDown

slideOutLeft

slideOutRight

slideOutUp

heartBeat

大功告成,刷新页面即可查看动画效果。

基本用法就是这些

官方还给出了一些进阶用法如下

二、进阶用法

动态调用动画的Javascript例子

function animateCss(element, animationName, callback) {

const node = document.querySelector(element)

node.classList.add('animated', animationName)

function handleAnimationEnd() {

node.classList.remove('animated', animationName)

node.removeEventListener('animationend', handleAnimationEnd)

if (typeof callback === 'function') callback()

}

node.addEventListener('animationend', handleAnimationEnd)

}

三、在官方例子基础上,稍加修改以后

由于官方例子用的是querySelector,故只会选中第一个符合要求的元素。

并且持续时间只有slow(2s)、slower(3s)、fast(800ms)、faster(500ms)

故我稍加修改,依然用的原生JS语法(部分ES6)

其中选择器element改为选中所有符合要求的元素

新增times参数,可以是2000ms或者2s

/**

* element: 选择器 例如 #id | .class | div

* animationName: 动画名称 参考animate.css官网 例如fadeIn

* times: 持续时间 例如 200ms | 2s

* callback: 回调函数

*/

function animateCss(element, animationName,times, callback) {

const nodes = document.querySelectorAll(element)

nodes.forEach((node => {

if(times) node.style.setProperty('animation-duration', times, 'important');

node.classList.add('animated', animationName)

function handleAnimationEnd() {

node.classList.remove('animated', animationName)

node.removeEventListener('animationend', handleAnimationEnd)

if (typeof callback === 'function') callback()

}

node.addEventListener('animationend', handleAnimationEnd)

}))

}

例子

animateCss('.post', 'pulse');

animateCss('.post', 'pulse','200ms');

animateCss('.post', 'pulse','200ms',function(){//do something});

Animate.css官网

另外本篇文章也发表在了我的个人主页,欢迎来查看

https://zzzmh.cn/single?id=59

html禁止页面动画,Animate.css 超强CSS3动画库,三行代码搞定H5页面动画特效!相关推荐

  1. Adobe源码泄漏?3行代码搞定,Flash动画无缝导入Android/iOS/cocos2dx(二)

    [注] iOS代码已重构,效率提升90%,200层动画不卡.[2016.10.27] 上一篇 点此阅读 简要介绍了FlashToAnimation的功能,也就是将flash动画无缝导入到Android ...

  2. Adobe源码泄漏?3行代码搞定,Flash动画无缝导入Android/iOS/cocos2dx(一)

    [注] iOS代码已重构,效率提升90%,200层动画不卡.[2016.10.27] 项目介绍 项目名称:FlashAnimationToMobile 源码. 使用方法点这里. 这是一个把flash中 ...

  3. Adobe源码泄漏?3行代码搞定,Flash动画无缝导入Android iOS cocos2dx(二)

    [注] iOS代码已重构,效率提升90%,200层动画不卡.[2016.10.27] 上一篇 点此阅读 简要介绍了FlashToAnimation的功能,也就是将flash动画无缝导入到Android ...

  4. vue动画效果-定义动画帧过度效果集成第三方动画animate.css

    1.定义动画帧 <template><div><button @click="isShow=!isShow">显示/隐藏</button& ...

  5. 前端进阶必学必会动画学习之Animate.css的使用与解析:一个强大而酷炫的CSS3动画库Animate.css使用方法教程

    简介 animate.css 是一个来自国外的 CSS3 动画库,它预设了抖动(shake).闪烁(flash).弹跳(bounce).翻转(flip).旋转(rotateIn/rotateOut). ...

  6. 强大的CSS3动画库animate.css

    今天要给大家介绍一款强大的CSS3动画库animate.css,animate.css定义了大概50多种动画形式,包括淡入淡出,文字飞入.左右摇摆动画等等.使用animate.css也非常简单,你可以 ...

  7. css动漫效果库,Animate.css功能强大的纯CSS3动画库 - 资源分享

    Animate.css是一个CSS3动画库,他为我们预设了很多可以使用的动画效果,比如弹跳.飘过.滑动.渐变的等特效,简单好用,只需要添加对应的动画Class到元素上,即可调用插件的动画效果,而且支持 ...

  8. animate.css –齐全的CSS3动画库--- 学习笔记

    animate.css – 齐全的CSS3动画库 学习网站: https://daneden.github.io/animate.css/ http://www.dowebok.com/98.html ...

  9. animate.css在vue中进行路由切换时的转场动画

    在做一些后台管理或者是一些跳转型的网站的时候我们会遇到用动画去切换,显得网站动态化效果强一点,毕竟vue框架属于单页面应用,有些时候一些动画会显得页面的逼格更高一点 在选择动画的时候我们绝大多数都会考 ...

  10. php magic模版插件,magic-带64种动画效果的CSS3动画库

    magic.css是一款带64种动画效果的CSS3动画库.magic.css中的动画分为12大类,全部使用CSS3 animation动画来完成.各种效果使用非常简单,只需要为元素添加和移除相应的cl ...

最新文章

  1. 让Linux修改IP、DNS等可以更简单
  2. Android 网络连接状态的监控
  3. JAVA面试中问及Hibernate与 Mybatis的对比
  4. 我国计算机网络事业发展,金标尺公考
  5. 全球数据库--基金/管理产品--分类/行业平均
  6. 从高量到高质,私域流量的变革与发展
  7. 解析Node.js通过axios实现网络请求
  8. 20130418定义全局变量
  9. 摘录:java和sql如何判断数据库是否存在
  10. MATLAB(五) 图像处理--图像分割
  11. matlab微积分如何计算器,如何用matlab对这个函数进行积分。 请问这个公式是如何算出来的?使用微积分吗?...
  12. strtolower
  13. 中国语料库研究的历史与现状-冯志伟教授
  14. 【华人学者风采】郑宇 京东
  15. web前端入门到实战:CSS颜色、背景和剪切
  16. 直方图均衡化、规定化、局部直方图、直方图统计
  17. HCIE必经之路(五)——OSPF综合实验(STUB及NSSA)
  18. 【Python】关键字
  19. 深入浅出滴聊聊NFC充值
  20. 2011金融考博经验谈(上交安泰金融篇)【zz】

热门文章

  1. 肯德基champs各个字母代表什么_百度知道
  2. 金山盛大成立合资公司
  3. arcgis构建金字塔失败什么原因_新西兰创业移民转永居失败!原因是什么?
  4. base64编码 vba_[VBA]Base64编码和Base64解码
  5. java架构师_阿里P8架构师分享:想成为Java架构师,必须掌握的几点技术
  6. 正在启动文档服务器,正在启动远程服务器
  7. linux 中文 bterm fbterm 内核,Fbterm (简体中文)
  8. 转:div中内容上下居中小结
  9. topcoder srm 704 div1
  10. web项目中图标的前端处理方案