当前位置: 首页 > news >正文

前端基础之动画效果

简单的入场与出场

<template>

  <div>

    <button @click="isShow=!isShow">显示/隐藏</button>

    <transition name="hello" appear><!--  appear设置打开界面就播放动画-->

    <h1 v-show="isShow"  >hello</h1>

    </transition>

  </div>

</template>

<script>

export default {

    name:'Test',

    data(){

        return{

            isShow:true

        }

    }

}

</script>

<style scoped>

h1{

    background-color: orange;

}

.hello-enter-active{              /* 进入的动画 */

  animation: atguigu 0.5s ;

}

.hello-leave-active{              /*退出的动画  */

  animation: atguigu 0.5s ;

}

@keyframes atguigu {

  from{

    transform: translateX(-100px);

  }

  to{

    transform: translateX(0px);

  }

}

</style>

<<QQ20241012-23644.mp4>>

过度效果

<template>

  <div>

    <button @click="isShow=!isShow">显示/隐藏</button>

    <transition name="hello" appear><!--  appear设置打开界面就播放动画-->

    <h1 v-show="isShow"  >hello2</h1>

    </transition>

  </div>

</template>

<script>

export default {

    name:'Test',

    data(){

        return{

            isShow:true

        }

    }

}

</script>

<style scoped>

h1{

    background-color: orange;

   

}

.hello-enter-active,.hello-leave-active{              /* 进入过程和退出过程 */

  transition: 0.5s linear;

}

.hello-enter,.hello-leave-to{                   /* 进入的起点与离开的终点 */

  transform: translateX(-100%);

}

.hello-enter-to ,.hello-leave{                /*进入的终点与离开的起点*/

  transform: translateX(0);

}

</style>

实现的动画效果与上面的一致

集成第三方库

1.首先需要进行下载

 npm install animate.css --save

2.标签中的name设置为

"animate__animated animate__bounce"  

在Animate.css | A cross-browser library of CSS animations.

中找到合适的动画的名称,进入复制

<template>

  <div>

    <button @click="isShow = !isShow">显示/隐藏</button>

    <transition

          name="animate__animated animate__bounce"        

          appear

          enter-active-class="animate__swing"

          leave-active-class="animate__backOutUp">

      <h1 v-show="isShow">hello3</h1>

    </transition>

  </div>

</template>

<script>

import 'animate.css'; // 确保 animate.css 已经被正确导入

export default {

  name: 'Test',

  data() {

    return {

      isShow: true

    }

  }

}

</script>

<style scoped>

h1 {

  background-color: orange;

}

</style>

<<QQ20241013-152021.mp4>>

相关文章:

  • 信贷风控系统架构设计
  • opencompass框架测试Deepseek使用教程
  • 【ORACLE】ORACLE19C在19.13版本前的一个严重BUG-24761824
  • js操作字符串的常用方法
  • 【万字长文】基于大模型的数据合成(增强)及标注
  • Pytorch的一小步,昇腾芯片的一大步
  • 【Elasticsearch】reindex
  • Pythonweb开发框架—Flask工程创建和@app.route使用详解
  • 33.C++二叉树进阶1(二叉搜索树两种模型及其应用)
  • 计算机毕业设计SpringBoot+Vue.js毕业设计管理系统(源码+文档+PPT+讲解)
  • FPGA学习篇——Verilog学习4
  • 13、TCP和UDP的区别【高频】
  • MYSQL的安装教程
  • Leetcode-100 完全平方数
  • Python——无损将 .mp4 转成 .gif
  • vue前端杂记
  • 亚马逊云科技Marketplace(中国区)上架专业服务产品, “云生态连接器”价值凸显
  • flask 安装后不能识别
  • 系统架构设计师-第3章 数据库设计
  • 【mysql】有索引和没有索引字段更新时锁的不同
  • 成都建设监理协会网站/app推广拉新一手渠道
  • 江门网站推广/怎么发帖子做推广
  • 嘉兴网站建设公司/网络推广方式主要有
  • 如何做网站的关键词排名/百度推广每年600元什么费用
  • 东莞建设网站/平台seo什么意思
  • 佛山哪里有做网站的/上优化seo