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>

教学视频地址

点击跳转教学视频

相关推荐
Canace1 分钟前
使用大模型来维护知识库
前端·人工智能
HashTang1 分钟前
用自然语言驱动的开源 3D 建筑设计编辑器-Aedifex
前端·github·ai编程
0vvv01 小时前
2026-NCTF-web-N-RustPICA
前端·ctf
前进的李工1 小时前
MySQL角色管理:权限控制全攻略
前端·javascript·数据库·mysql
芯智工坊1 小时前
第13章 Mosquitto监控与日志管理
前端·网络·人工智能·mqtt·开源
洒满阳光的庄园1 小时前
Electron 桌面端打包流程说明
前端·javascript·electron
Jagger_1 小时前
模型能力边界外扩时,工作到底在怎样被重做?
前端
SuperEugene1 小时前
前端通用基础组件设计:按钮/输入框/弹窗,统一设计标准|组件化设计基础篇
前端·javascript·vue.js·架构
Jagger_2 小时前
# 模型边界往外推的时候,我最怕的不是学不会,是没人听我解释
前端
OpenTiny社区2 小时前
Chrome 内置「AI 外挂」?NEXTSDK 让浏览器自己调 API、抓数据、填表单!
前端