uni-app/vue 引入 Animate.css (好看且实用的动画库)

开发一个程序的时候,我们总想着程序能有各种各样的组件效果 比如弹跳的球等等,像ppt动画那样的效果 整合了Animate.css我们程序的逼格会高很多的,相信我~

Animate.css官网 https://animate.style/

这个网站uni-app云开发教程也是整合了Animate.css

引入

执行 npm install animate.css --save

在main.js中 import 'animate.css';

图片.png

如何使用

这里我们写了一个简单的测试

1<template> 2 <view> 3 <view class="test">我来了~</view> 4 </view> 5</template> 6<style> 7 .test { 8 text-align: center; 9 font-size: 40px; 10 animation: bounce; 11 animation-duration: 2s; 12 animation-iteration-count: 10; 13 } 14</style>

效果如下图 是不是动起来了 哈哈哈哈哈哈哈哈哈~~ dds.gif

制作一个球

dds.gif 是不很有意思呢 那么他是怎么实现的呢

一个圆形

使用view组件 基础的样式如下 下面的样式让我们得到了一个球

1.funs { 2 width: 100px; 3 height: 100px; 4 border-radius: 100px; 5 background-color: #ffffff; 6 position: fixed; 7 text-align: center; 8 }

下落

1.ball_one { 2 animation: bounceInDown; 3 /* referring directly to the animation's @keyframe declaration */ 4 animation-duration: 2s; 5 /* don't forget to set a duration! */ 6 }

原地跳动

1.bail_fone { 2 animation: bounce; 3 animation-duration: 2s; 4 animation-iteration-count: infinite; 5 }

首先,需要下落球,落下后开始跳动 那么我们给球下落时间为2s 两秒后切换球的样式 让其开始跳动 那么怎么实现呢? 猜的没错 是 :class

完整代码

1<template> 2 <view style="background-color: #000000;width: 100%;height: 100vh;"> 3 <view class="one funs" :class="{ball_one:!isAni,bail_fone:isAni}"></view> 4 </view> 5</template> 6 7<script> 8 export default { 9 data() { 10 return { 11 isAni: false 12 } 13 }, 14 onLoad() { 15 setTimeout(() => { 16 this.isAni = true; 17 }, 2600) 18 }, 19 methods: { 20 21 } 22 } 23</script> 24 25<style> 26 27 .one { 28 bottom: 150px; 29 left: 150px; 30 background-size: cover; 31 } 32 33 .funs { 34 width: 100px; 35 height: 100px; 36 border-radius: 100px; 37 background-color: #ffffff; 38 position: fixed; 39 text-align: center; 40 } 41 42 .ball_one { 43 animation: bounceInDown; 44 /* referring directly to the animation's @keyframe declaration */ 45 animation-duration: 2s; 46 /* don't forget to set a duration! */ 47 } 48 49 .bail_fone { 50 animation: bounce; 51 animation-duration: 2s; 52 animation-iteration-count: infinite; 53 } 54</style> 55

实现一个组合框拼接

首先这是静态的时候的样子 图片.png

这是动态的样子 dds.gif

第一个字从上面下落

dds.gif

样式

1.test_one { 2 animation: backInDown; 3 animation-duration: 2s; 4 }

第二个字左侧进入

不再展示 直接上代码

1.test_two { 2 animation: backInLeft; 3 animation-duration: 2s; 4 }

第三个字右侧进入

代码如下

1.test_three { 2 animation: backInRight; 3 animation-duration: 2s; 4 }

第四个字下到上

代码如下

1.test_four { 2 animation: backInUp; 3 animation-duration: 2s; 4 }

拓展

我们可以再加一个自我结束 比如 哈喽,小伙伴们大家好,我是代码哈士奇 效果如下 dds.gif

怎么实现的呢 很简单 如下

1.test_list { 2 font-size: 30px; 3 margin-top: 40px; 4 animation: fadeInDown; 5 animation-duration: 3s; 6 }

整体代码

1<template> 2 <view style="position: relative;top: 60px;"> 3 <view class="f_t test_one"></view> 4 <view class="f_t test_two"></view> 5 <view class="f_t test_three"></view> 6 <view class="f_t test_four"></view> 7 <view class="f_t test_list">哈喽,小伙伴们大家好,我是代码哈士奇</view> 8 </view> 9</template> 10<style> 11 .f_t{ 12 text-align: center; 13 font-size: 40px; 14 } 15 .test_one { 16 animation: backInDown; 17 animation-duration: 2s; 18 } 19 20 .test_two { 21 animation: backInLeft; 22 animation-duration: 2s; 23 } 24 25 .test_three { 26 animation: backInRight; 27 animation-duration: 2s; 28 } 29 30 .test_four { 31 animation: backInUp; 32 animation-duration: 2s; 33 } 34 35 .test_list { 36 font-size: 30px; 37 margin-top: 40px; 38 animation: fadeInDown; 39 animation-duration: 3s; 40 } 41</style> 42

总结

是不是很简单 其实关键就是 animation: xxxx; 这里的xxxx呢 其实就是就是红框中的那些 可以自行尝试哦 还可以在大屏中使用哦 图片.png

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )