如何使用动画库animate.css
animate.css是一个CSS3动画库,里面预设了抖动(shake)、闪烁(flash)、弹跳(bounce)、翻转(flip)、旋转(rotateIn/rotateOut)、淡入淡出(fadeIn/fadeOut)等多达 60 多种动画效果。你可以点击打开它的 官网 查看演示,里面几乎包含了所有常见的动画效果。妈妈在也不用担心我不会写动画了!!!
演示地址 动画演示地址。
下载地址链接 点击下载地址链接下载,打开的是一个css文件 直接Ctrl+A全选 Ctrl+C复制即可。
如何使用:
先来看一个简单的示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- 引入 animate.css -->
<link rel="stylesheet" href="./css/animate.css">
<style>
.box {
width: 200px;
height: 200px;
margin: 0 auto;
background-color: pink;
}
</style>
</head>
<body>
<!-- 打开浏览器就可以看到其效果了 -->
<div class="box animated bounce">盒子</div>
</body>
</html>
首先页面引入 animate.css。 把 animated 添加到类属性上, animated 是动画的一个基类每个动画都必须添加紧接着后面就是 动画名。
例如:
<div class="box animated jello">盒子</div>
原生js添加动画示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- 引入 animate.css -->
<link rel="stylesheet" href="./css/animate.css">
<style>
.box {
position: relative;
left: 78px;
width: 200px;
height: 200px;
margin: 0 auto;
background-color: pink;
}
button { display: block; margin: auto;}
</style>
</head>
<body>
<div class="box" id="box">盒子</div>
<button id="btn">点我</button>
<script>
// 获取盒子和按钮
var box = document.getElementById('box');
var btn = document.getElementById('btn');
// 给 按钮 绑定一个单击事件只要触发了就执行这个匿名函数
btn.onclick = function() {
// 给盒子添加动画 基类 和类名
box.classList.add('animated','bounce');
}
</script>
</body>
</html>
jQuery添加动画类示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- 引入 animate.css -->
<link rel="stylesheet" href="./css/animate.css">
<!-- 引入 jquery.js -->
<script src="./js//jquery3.4.1min.js"></script>
<style>
.box {
position: relative;
left: 78px;
width: 200px;
height: 200px;
margin: 0 auto;
background-color: pink;
}
button { display: block; margin: auto;}
</style>
</head>
<body>
<div class="box" id="box">盒子</div>
<script>
$(function() {
var $this = $('#box');
$this.hover(function() {
$this.addClass('box animated bounce');
},function() {
$this.removeClass('animated bounce');
})
})
</script>
</body>
</html>
至于动画其他的配置参数,如动画持续时间,动画的执行次数等等,你可以在你的的元素上自行定义,覆盖掉animate.css里面所定义的就好了。
如何使用动画库animate.css的更多相关文章
- 强大的CSS3动画库animate.css
今天要给大家介绍一款强大的CSS3动画库animate.css,animate.css定义了大概50多种动画形式,包括淡入淡出,文字飞入.左右摇摆动画等等.使用animate.css也非常简单,你可以 ...
- css3动画简介以及动画库animate.css的使用
在这个年代,你要是不懂一点点css3的知识,你都不好意思说你是个美工.美你妹啊,请叫我前端工程师好不好.呃..好吧,攻城尸...呵呵,作为一个攻城尸,没有点高端大气上档次的东西怎么能行呢,那么css3 ...
- 转: css3动画简介以及动画库animate.css的使用
~~~ transition animation 和 animate.css 在这个年代,你要是不懂一点点css3的知识,你都不好意思说你是个美工.美你妹啊,请叫我前端工程师好不好.呃..好吧,攻城 ...
- 【转载】css3动画简介以及动画库animate.css的使用
原文地址:http://www.cnblogs.com/2050/p/3409129.html 在这个年代,你要是不懂一点点css3的知识,你都不好意思说你是个美工.美你妹啊,请叫我前端工程师好不好. ...
- 动画库animate.css的用法
简介 animate.css是一个来自国外的 CSS3 动画库,它预设了引起弹跳(bounce).摇摆(swing).颤抖(wobble).抖动(shake).闪烁(flash).翻转(flip).旋 ...
- CSS动画库——animate.css的使用
Animate.css是一款强大的CSS3动画库 官网地址:https://daneden.github.io/animate.css/ 使用方法如下所示: (1)下载animate.css 下载地址 ...
- 使用CSS3动画库animate.css
IE9及更早版本的IE浏览器都不支持css3动画 谷歌浏览器.火狐浏览器.IE10+浏览器以及移动端浏览器等这些都支持css3动画 animate.css内置了很多典型的css3动画 用法 1 ...
- 动画库Animate.css
笔记分享: 用法:到官网(http://daneden.github.io/animate.css/),下载animate.min.css文件.点击这里 1.首先引入animate css文件 < ...
- CSS3动画库——animate.css
初见animate.css的时候,感觉很棒,基本上很多常用的CSS3动画效果都帮我们写好了,所以想要哪一种效果直接就可以拿过来用,甚是方便: 效果展示官网:http://daneden.github. ...
随机推荐
- Git 时光穿梭鸡 撤销修改
工作区内容修改了, 但是并未add到暂存区, 想 回退到上一个版本 在readme.txt中添加了一行: Git is a distributed version control system. Gi ...
- php如何运行
这篇文章,研究一下php代码是如何解释和执行以及PHP脚本运行的生命周期. 概述 PHP服务的启动.严格来说,PHP的相关进程是不需要手动启动的,它是随着Apache的启动而运行的.当然,如果有需要重 ...
- Mysql相关函数使用和总结(liet、right、substring、substring_index)
一.字段截取 1.从左开始截取字符串 用法:left(str,length),即:leift(被截取字符串,截取长度) 列子:select left(‘www.baidu.com’,8) 结果:www ...
- jquery jtemplates.js模板渲染引擎的详细用法第二篇
jquery jtemplates.js模板渲染引擎的详细用法第二篇 关于jtemplates.js的用法在第一篇中已经讲过了,这里就直接上代码,不同之处是绑定模板的方式,这里讲模板的数据专门写一个t ...
- std::less
std::less 定义于头文件 <functional> template< class T >struct less; (C++14 前) template ...
- Mysql 5.7 账户过期重启
关闭mysql 重启mysql57
- 2017swpu-ctf总结
2017swpu-ctf总结 今年是我第一次出题感受很多,就分析几道我印象最深刻的题吧 你能进入后台吗? 这道题主要是考察php_screw还有md5加密开启true过后的注入 phpscrew加密在 ...
- CodeForces - 507B - Amr and Pins(计算几何)
Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r ...
- js window对象属相和方法相关整理资料
window对象有以下方法: open close alert confirm prompt setTimeout clearTimeout setInterval clearInterval mov ...
- es6新语法系列,查找字符串,模板字符串
一.模板字符串: ES6引入了一种新型的字符串字面量语法,我们称之为模板字符串(template strings).除了使用反撇号字符 ` 代替普通字符串的引号 ' 或 " 外,它们看起来与 ...