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>

教学视频地址

点击跳转教学视频

相关推荐
执子念的飞鱼23 分钟前
File Viewer 进入 2K 节点后,我更在意这 3 条回归
前端·typescript
richdata24 分钟前
动态OTB vs 静态OTB:鞋服零售该选哪种管理模式?
前端·html·零售
Jodie同志27 分钟前
第16~23天:持久化、HITL、流式、MCP与安全
前端·后端·agent
Jodie同志31 分钟前
第1~15天:原生Agent、RAG与LangGraph基础(完整代码实操)
前端·后端·agent
sunly_33 分钟前
React useActionState 的用法详解
前端·javascript·react.js
今日无bug34 分钟前
RESTful + Interface:从 todos 项目理解后端接口设计
前端·restful
用户693717500138442 分钟前
#DeepSeek+Pi‑Agent 王炸组合跑赢 Claude‑Code!
前端·人工智能·后端
前端一课1 小时前
我还在上班,怎么做一个长期有价值的号
前端
前端一课1 小时前
用 TRAE Work 把项目踩坑经验沉淀成「团队可复用工程规范」,新人再也不重复掉坑
前端·后端
cyadyx1 小时前
【Three.js】Three.js 中加载 3D 模型
前端·javascript·3d