animate.css的使用

animate.css是一个CSS3动画库,它的里面预设了许多的常用动画。因为它把不同动画效果绑定到的是不同的类里面,所以我们想要使用的话,只需要先引用animate.css文件,再把你想要使用的那个类添加到元素上面就可以了。

第一步:引入animate.css文件:

可使用:http://www.bootcdn.cn/animate.css/的服务

<head>
  <link rel="stylesheet" href="animate.min.css">
</head>

第二步:在需要添加效果的元素上加上想要实现的动画样式名

第一个animated是必须添加的样式名,第二个是指定的动画样式名。

<div class="animate__animated animate__slideInLeft">

其他补充:(采用jquery可以不修改现有代码,动态添加动画

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;    //动画执行次数
}

常用的动画:

Attention seekers(寻求关注者)
bounce        
flash         
pulse        
rubberBand
shakeX
shakeY
headShake
swing
tada
wobble
jello
heartBeat


Back entrances(返回入口)
backInDown
backInLeft
backInRight
backInUp


Back exits(返回出口)
backOutDown
backOutLeft
backOutRight
backOutUp


Bouncing entrances(弹跳入口)
bounceIn
bounceInDown
bounceInLeft
bounceInRight
bounceInUp


Bouncing exits(弹跳出口)
bounceOut
bounceOutDown
bounceOutLeft
bounceOutRight
bounceOutUp


Fading entrances(淡出的入口)
fadeIn
fadeInDown
fadeInDownBig
fadeInLeft
fadeInLeftBig
fadeInRight
fadeInRightBig
fadeInUp
fadeInUpBig
fadeInTopLeft
fadeInTopRight
fadeInBottomLeft
fadeInBottomRight


Fading exits(退场出口)
fadeOut
fadeOutDown
fadeOutDownBig
fadeOutLeft
fadeOutLeftBig
fadeOutRight
fadeOutRightBig
fadeOutUp
fadeOutUpBig
fadeOutTopLeft
fadeOutTopRight
fadeOutBottomRight
fadeOutBottomLeft


Flippers(脚蹼)
flip
flipInX
flipInY
flipOutX
flipOutY


Lightspeed(光速)
lightSpeedInRight
lightSpeedInLeft
lightSpeedOutRight
lightSpeedOutLeft


Rotating entrances(旋转入口)
rotateIn
rotateInDownLeft
rotateInDownRight
rotateInUpLeft
rotateInUpRight


Rotating exits(旋转出口)
rotateOut
rotateOutDownLeft
rotateOutDownRight
rotateOutUpLeft
rotateOutUpRight


Specials(特殊)
hinge
jackInTheBox
rollIn
rollOut


Zooming entrances(缩放入口)
zoomIn
zoomInDown
zoomInLeft
zoomInRight
zoomInUp


Zooming exits(缩放出口)
zoomOut
zoomOutDown
zoomOutLeft
zoomOutRight
zoomOutUp


Sliding entrances(滑动入口)
slideInDown
slideInLeft
slideInRight
slideInUp


Sliding exits(滑动出口)
slideOutDown
slideOutLeft
slideOutRight
slideOutUp

参考文章:animate中文网

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Vue Animate.css 是一个 Vue.js 的插件,它可以让你轻松地在 Vue.js 应用程序中使用 Animate.css 动画库。使用 Vue Animate.css,你可以通过简单的指令来添加动画效果,而不需要编写任何 JavaScript 代码。下面是使用 Vue Animate.css 的步骤: 1. 安装 Vue Animate.css 插件: ``` npm install vue-animate-css ``` 2. 在 Vue.js 应用程序中引入 Vue Animate.css 插件: ``` import Vue from 'vue' import VueAnimateCss from 'vue-animate-css' Vue.use(VueAnimateCss) ``` 3. 在 Vue.js 组件中使用指令来添加动画效果: ``` <template> <div v-animate="'bounce'">Hello, world!</div> </template> ``` 在上面的例子中,我们使用 `v-animate` 指令来添加 `bounce` 动画效果。你可以在 Vue Animate.css 文档中找到更多可用的动画效果。 希望这个回答能够帮助你! ### 回答2: Vue animate.css是一款非常方便实现各种动画的工具。它是基于开源库animate.css开发而来,使得在Vue项目中使用动画效果变得更为便捷。 首先,在Vue项目中还需要安装vue-animate-css这个插件以便使用这款工具。可以使用npm包管理工具来安装它,输入以下命令然后等待安装完成。 npm install vue-animate-css --save 使用这个工具的方式通常有三种: 1. 以组件的方式使用: 在需要使用动画效果的组件内,引入vue-animate-css库并且设置样式class即可。例如: ``` <template> <div> <h1 :class="animatedClass">例子</h1> </div> </template> <script> import {hover, fadeIn} from 'vue-animate-css'; export default { data: () => ({ animatedClass: hover + ' ' + fadeIn }) } </script> ``` 2. 作为全局 mixin: 使用全局mixin方法后,在整个Vue项目内都可以方便地使用动画效果。比如: ``` import Vue from 'vue'; import {bounce} from 'vue-animate-css'; Vue.mixin({ methods: { bounce: bounce } }); ``` 在使用时只需要在需要使用效果的元素上添加样式类名即可。 3. 通过指令使用: 通过指令使用在有些情况下更为直观。在使用前需要先在Vue项目中引入animate.css库。比如: ``` import 'animate.css/animate.min.css'; import Vue from 'vue'; Vue.use({ install(Vue) { Vue.directive('animate', { inserted: (el, binding) => { el.addEventListener('animationend', () => { el.classList.remove(binding.value, 'animated'); }); el.classList.add('animated', binding.value); } }); } }); ``` 在使用指令的组件中,可以在需要使用动画效果的元素上添加v-animate指令,比如: ``` <template> <div> <h1 v-animate="'bounce'">例子</h1> </div> </template> ``` 这样就可以实现元素在页面加载时弹跳一次的效果。 总的来说,vue animate.css是一个非常实用的库,可以便捷地实现各种动画效果。具体使用方法可以根据自己的项目需求来灵活运用。 ### 回答3: Vue animate.css是一款能够为Vue应用程序添加动画效果的插件。它通过使用animate.css框架中的动画类名称,实现了Vue动态展示元素的效果。使用Vue animate.css可以省去手写CSS或Javascript动画的烦琐操作,同时可以方便地实现页面元素的动态效果,提升用户体验。 Vue animate.css使用方法如下: 1. 安装Vue animate.css插件,在命令行中运行以下命令: ``` npm install vue-animate-css --save ``` 2. 在Vue组件中引入vue-animate-css的插件: ``` import VueAnimateCss from 'vue-animate-css'; Vue.use(VueAnimateCss); ``` 3. 在组件的模板中添加需要动画效果的元素,并绑定动画类名称: ``` <template> <div> <h1 v-animate-css="'bounceIn'" class="animated">{{ message }}</h1> </div> </template> ``` 4. 在组件的样式表中引入animate.css框架,并为绑定动画类名称的元素添加相应的样式: ``` <style> @import "animate.css"; .animated { animation-duration: 1s; } </style> ``` 5. 在运行应用程序时,就可以看到具有动态效果的元素了。 在以上的使用方法中,v-animate-css即为绑定动画类名称的指令,'bounceIn'为animate.css框架中的一个动画类名称,可以根据需要自由更换。同时,样式表中的animation-duration属性可控制动画持续的时间。 总之,使用Vue animate.css可以在Vue应用程序中方便地实现动态效果,增强用户体验,并且简化了开发人员的操作。但需要注意的是,为了保证页面的性能,应适度使用动画效果,以避免过度设计的问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值