CSS 文字弹跳效果

鼠标移过去 会加快速度

复制代码
<template>
 <div class="bounce">
   <p class="text" :style="{animationDuration: animationDuration}">
     欢迎使用UniApp Vue3!
   </p>
 </div>
</template>

<script>
export default {
 name: 'Bounce',
 data() {
   return {
     animationDuration: '0.5s',
   };
 },
 mounted() {
   this.$el.querySelector('.text').addEventListener('mouseover', () => {
     this.animationDuration = '0.2s';
   });

   this.$el.querySelector('.text').addEventListener('mouseout', () => {
     this.animationDuration = '0.5s';
   });
 },
};
</script>

<style scoped>
.bounce {
 display: flex;
 justify-content: center;
 align-items: center;
 height: 100vh;
}

.text {
 font-size: 24px;
 font-weight: bold;
 color: #333;
 animation: bounce 1s infinite;
}

@keyframes bounce {
 0% {
   transform: translateY(0);
 }
 50% {
   transform: translateY(-30px);
 }
 100% {
   transform: translateY(0);
 }
}
</style>

教学视频地址

点击跳转教学视频

相关推荐
lpfasd1236 小时前
node-sass 停止维护!老项目迁移 Dart Sass 完整教程
前端·rust·sass
Data analyse4568 小时前
rnweb 回放数据量太大怎么办?分片存储与断点续传的实现思路
前端·网络·算法·数据分析
xiaogai_gai8 小时前
金蝶收料通知单查询策略实战教程:从源系统拉取到中间层落地的完整路径
java·前端·数据库
环境栈笔记9 小时前
指纹浏览器 WebRTC 怎么设置?从 ICE 候选、代理出口到功能验证
前端·人工智能·后端·自动化
赵大仁9 小时前
官网性能优化实战:LCP 3.2s → 2.1s、CLS 0.107 → 0,以及被我推翻的 6 个判断
前端·性能优化·cls·lcp·core web vitals
xiancai_xianyu10 小时前
Text2SQL落地生产库前,SQL要过哪三道闸
前端·数据库·sql·sql注入·text2sql·ai agent开发·企业级ai框架
小羊没烦恼!10 小时前
T-SQL查询进阶--理解SQL SERVER中的分区表
服务器·开发语言·前端·javascript·html
史瓦辛格10 小时前
给 DeepSeek Harness 写费用插件:把「这次会话花了多少钱」算准
前端·deepseek
星光不问赶路人10 小时前
Vue 3 + TypeScript 中 enum 的使用实践
前端·vue.js
鸥梨菌Honevid10 小时前
UVM 中 REQ 和 RSP 类型详解:从通信模型到 item_done 与 put_response
java·前端·servlet