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>

教学视频地址

点击跳转教学视频

相关推荐
kymjs张涛10 分钟前
前沿技术周刊 2025-06-09
android·前端·ios
前端康师傅14 分钟前
JavaScript 变量详解
前端·javascript
Sun_light15 分钟前
队列:先进先出的线性数据结构及其应用
前端·javascript·算法
Data_Adventure18 分钟前
如何在本地测试自己开发的 npm 包
前端·vue.js·svg
萌萌哒草头将军29 分钟前
⚓️ Oxlint 1.0 版本发布,比 ESLint 快50 到 100 倍!🚀🚀🚀
前端·javascript·vue.js
ak啊33 分钟前
WebGL入门教程:实现场景中相机的视角与位置移动
前端·webgl
天天打码38 分钟前
Sass具有超能力的CSS预处理器
前端·css·sass
Yana.nice1 小时前
sysctl优先级顺序
服务器·前端·网络
米花丶1 小时前
异步加载弹出层动画丢失问题
前端
小桥风满袖1 小时前
Three.js-硬要自学系列31之专项学习动画混合
前端·css·three.js