Animate动画库使用 | 您所在的位置:网站首页 › 如何为元素添加css动画效果 › Animate动画库使用 |
官网链接 http://www.animate.net.cn/ 使用步骤 第一步. 引入animate.css文件 第二步. 给指定的元素加上指定的动画样式名 其他1.如果说想给某个元素动态添加动画样式,可以通过jquery来实现: $('#yourElement').addClass('animated bounceOutLeft');2.当动画效果执行完成后还可以通过以下代码添加事件 $('#yourElement').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', doSomething);3.你也可以通过 JavaScript 或 jQuery 给元素添加这些 class,比如: $(function(){ $('#yourElement').addClass('animated bounce'); });4.有些动画效果最后会让元素不可见,比如淡出、向左滑动等等,可能你又需要将 class 删除,比如: $(function(){ $('#yourElement').addClass('animated bounce'); setTimeout(function(){ $('#yourElement').removeClass('bounce'); }, 1000); });5.animate.css 的默认设置也许有些时候并不是我们想要的,所以你可以重新设置,比如: #yourElement{ animate-duration: 2s; //动画持续时间 animate-delay: 1s; //动画延迟时间 animate-iteration-count: 2; //动画执行次数 } 样式:https://animate.style/ 实际开发中使用 1.移入移出图片添加动画效果使用JQ. 直接使用类名添加的话会导致移入其中某一个所有有这个类名的元素都有反应,所以使用this,来辨别当前这个元素. $(".pic").hover( function(){ $(this).addClass("animated").addClass("pulse"); }, // 移入 function(){ $(this).removeClass("animated").removeClass('pulse'); }, // 移出 ) |
CopyRight 2018-2019 实验室设备网 版权所有 |