700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > CSS使用Animate.css制作动画效果【HTML】

CSS使用Animate.css制作动画效果【HTML】

时间:2022-12-12 18:01:03

相关推荐

CSS使用Animate.css制作动画效果【HTML】

web前端|html教程

CSS使用Animate.css制作动画效果

web前端-html教程

一 使用Animate.css动画

加密网址源码,ubuntu安装vga桌面,爬虫教案及反思,php获取两个值之间所有值,seo考试流程lzw

// 通过@import引入外部CSS资源;

看若依源码有用吗,Ubuntu还原精灵,爬虫爬取房价,php ci文档,seo 很有用lzw

// 引入线上图片及JS文件;

95自动发卡源码,vscode 搜索文件,ubuntu禁用u盘,tomcat 获取域名,sqlite 中文列名,高防云服务器代理,cookie登录插件下载,前端框架如何导出,爬虫12306,php卷A,黑帽seo海瑶,旅游网站系统功能,显示网页菜单栏,html模板 商城,页面加载动画,企业人事管理系统模板,返利网 程序lzw

// 通过更改CSS类名生成不同类型的CSS3动画;

1 2 34567 /* Animate.css GitHub地址:/daneden/animate.css */ 8 /* Animate.css 演示地址:https://daneden.github.io/animate.css/ */ 9 10 @import url("/animate.css/3.1.1/animate.min.css");11 body {12 background: #cfcfcf;13 }14 img {15 position: absolute;16 left: 50%;17 top:50%;18 margin-left: -100px;19 margin-top: -100px;20 width:200px;21 height:200px;22 }23 24252627282930 function rock (x) { // 定义事件函数;31 $(img).not(.center)32.addClass(x + animated)// 添加CSS类名;33.one(webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend34,function(){35 $(this).removeClass();36});37 };38 39 $(document).ready(function(){40 rock("rubberBand infinite");// 添加CSS类名生成相应的动态效果;41 setTimeout(function(){window.lcation.href = ""},6000);42 // 设置时间跳转;43 });4445

二 自定义Animate.css动画

// 可以使用animate.css代码作为基础,编写自定义的动画效果;

1 @keyframes bounce {/*通过@keyframes规则,创建bounce动画;*/ 20%,20%,50%,80%,100% { 3 transform:translateY(0); 4} 540% { 6 transform:translateY(-30px); 7} 860% { 9 transform:translateY(-15px);10}11 }12 .bounce {13animation-name:bounce; /*调用bounce动画;*/14 }15 .animated {16animation-duration:3s; /*一个动画周期的时长;*/17animation-fill-mode:both; /*指定动画执行之前之后的样式;*/18 }19 .animated.infinite {20animation-iteration-count:infinite; /*定义动画播放的次数;(n次/infinite无限次);*/21 }

1

三 使用JavaScript控制动画

1 $(img).click(function(){ // 给Img元素绑定点击事件;2var $this = $(this);// 鼠标点击之后添加相应的动画类名; 3$this.addClass(animated bounce).one(webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend,function(){4 // 当-webkit-animation动画结束之后会有一个webkitAnimationEnd事件;5 // 当one()方法监听到webkitAnimationEnd事件之后才执行function函数;one()方法只能执行一次;6 $this.removeClass(); // 清除相应的动画类名;7})8 });

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。