animate.css动画库+wow.js实现滚动到可视区域显示动画

1.安装animate.css动画库

npm install animate.css ;

2.安装wow.js

  npm install wowjs --save

3.在mian.js导入

import 'animate.css'//导入animate.css
import wow from 'wowjs'//全局导入wow.js
Vue.prototype.$wow = wow //全局注册到Vue实例中

 4.在组件中使用(定义mouted使得组件在渲染之前挂在wowjs)

mounted () {
    new this.$wow.WOW().init({//新建实列
      boxClass: 'wow',//class名字
      animateClass: 'animate__animated',//animateclass动画库类名,和当前animate动画库决定
      offset: 0,//到元素距离触发动画(当默认为0)
      mobile: true,//在移动设备上触发动画(默认为true)
      live: true//对异步加载的内容进行操作(默认为true)
    })
  },

5.在元素上使用(结合animate动画库使用)

例:

 <div class="wow animate__animated animate__fadeInLeftBig">
//animate__animated(基础类名,跟随animate_animated动画库说明)
//animate__fadeInLeftBig(动画效果类名)

6.好了大功告成!可以去看效果了。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,这里给你提供一种使用自定义类名和animate.css动画给一张图片添加入场动画的示例。使用animate.css可以方便地实现CSS动画效果,具体可以根据需求自定义。 首先,需要在HTML文件中引入animate.css的CDN链接: ```html <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" /> ``` 然后,HTML代码如下: ```html <div class="image-wrapper animate__animated"> <img src="image.jpg" alt="图片"> </div> ``` CSS代码如下: ```css .image-wrapper { position: relative; display: inline-block; } .image-wrapper.animate__animated { animation-duration: 1s; /* 设置动画持续时间 */ animation-delay: 0.5s; /* 设置动画延迟时间 */ animation-fill-mode: both; /* 设置动画结束后保持最后状态 */ animation-name: slideInLeft; /* 设置动画名称 */ } @keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } } .image-wrapper img { display: block; max-width: 100%; height: auto; } ``` 这段代码使用了animate.css中的slideInLeft动画效果,通过给`.image-wrapper`添加类名`.animate__animated`来触发动画效果。其中,`.image-wrapper.animate__animated`使用了CSS3的动画属性animation,通过设置animation-duration、animation-delay、animation-fill-mode、animation-name属性来定义动画效果。同时,利用@keyframes定义了从左侧平移进入的动画效果。最后,`.image-wrapper img`设置了图片的基本样式,其中max-width: 100%可以确保图片的宽度不会超出其容器的宽度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值