Animate.css是一款有趣的,跨浏览器的css3动画库,可以非常简单的实现各种炫酷的动画效果,可以在项目中使用。
安装
1.通过Bower安装:执行以下操作:
$ bower install animate.css --save
2.通过npm进行安装:执行以下操作:
$ npm install animate.css --save
基本用法
1、首先引入animate.css文件
<head>
<link rel="stylesheet" href="animate.min.css">
</head>
2、给指定的元素加上指定的动画样式名
<div class="animated bounceOutLeft"></div>
<!--这里包括两个class名,第一个是基本的,必须添加的样式名,任何想实现的元素都得添加这个。第二个是指定的动画样式名。-->
3、可以添加infinite样式名实现无限循环
<div class="animated infinite bounceOutLeft"></div>
4、如果说想给某个元素动态添加动画样式,可以通过jquery来实现:
$('#yourElement').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', doSomething);
5、你也可以通过 JavaScript 或 jQuery 给元素添加这些 class,比如:
$(function(){
$('#yourElement').addClass('animated bounce');
});
6、有些动画效果执行会使元素不可见,比如淡出、向左滑动等等,你可以将 class 删除:
$(function(){
$('#yourElement').addClass('animated bounce');
setTimeout(function(){
$('#yourElement').removeClass('bounce');
}, 1000);
});
7、animate.css 的默认设置也许并不是我们想要的,您可以更改动画的持续时间,添加延迟或更改播放次数:
#yourElement{
animate-duration: 2s; //动画持续时间
animate-delay: 1s; //动画延迟时间
animate-iteration-count: 2; //动画执行次数
}
(adsbygoogle = window.adsbygoogle || []).push({});
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有