Animate.css是一个有趣的,跨浏览器的css3动画库。很值得我们在项目中引用。
用法
1、首先引入animate css文件
1 2 3 4 5 6 7 8 |
<head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" /> </head> |
2、给指定的元素加上指定的动画样式名
1 2 3 |
<h1 class="animate__animated animate__bounce">An animated element</h1> |
这里包括两个class名,第一个是基本的,必须添加的样式名,任何想实现的元素都得添加这个。第二个是指定的动画样式名。
3、如果说想给某个元素动态添加动画样式,可以通过jquery来实现:
1 2 3 4 |
$('#yourElement').addClass('animated bounceOutLeft'); |
4、当动画效果执行完成后还可以通过以下代码添加事件
1 2 3 4 |
$('#yourElement').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', doSomething); |
1 2 3 4 5 6 |
$(function(){ $('#jq22').addClass('animated bounce'); }); |
1 2 3 4 5 6 7 8 9 |
$(function(){ $('#jq22').addClass('animated bounce'); setTimeout(function(){ $('#jq22').removeClass('bounce'); }, 1000); }); |
1 2 3 4 5 6 |
<h1>jq22{</h1>animate-duration: 2s; //动画持续时间 animate-delay: 1s; //动画延迟时间 animate-iteration-count: 2; //动画执行次数</pre> } |