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>

教学视频地址

点击跳转教学视频

相关推荐
Csvn24 分钟前
Monorepo
前端
Csvn26 分钟前
流水线
前端
Csvn36 分钟前
微前端架构
前端
Linux-lucky2 小时前
45-Linux学习之旅之防火墙与WEB加固
linux·前端·网络·学习·ubuntu
风骏时光牛马4 小时前
生成一个移动端标题,只需要一个标题,不需要其他的任何文本。
前端
IT_陈寒5 小时前
Redis雪崩把我坑惨了,这是5年经验的教训
前端·人工智能·后端
SameX5 小时前
HarmonyOS ArkUI List 的侧滑删除 用 ListItem 的 swipeAction + endIcon 的做法
前端
usdoc文档预览7 小时前
USDOC系列之PPT文件在线编辑-VUE前端实现在线浏览器在线编辑PPT文档
前端·vue.js·编辑器·office365·ppt在线编辑·office文件在线编辑·文件在线编辑
用户2705077725247 小时前
Agent 调工具卡住?3 种超时与取消策略实测对比
前端
LuHang8 小时前
我一行代码没写,把领导派的活做成了公司内部系统😭
前端