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>

教学视频地址

点击跳转教学视频

相关推荐
J***Q2923 小时前
Vue数据可视化
前端·vue.js·信息可视化
ttod_qzstudio5 小时前
深入理解 Vue 3 的 h 函数:构建动态 UI 的利器
前端·vue.js
_大龄5 小时前
前端解析excel
前端·excel
一叶茶5 小时前
移动端平板打开的三种模式。
前端·javascript
前端大卫5 小时前
一文搞懂 Webpack 分包:async、initial 与 all 的区别【附源码】
前端
Want5956 小时前
HTML音乐圣诞树
前端·html
老前端的功夫6 小时前
前端浏览器缓存深度解析:从网络请求到极致性能优化
前端·javascript·网络·缓存·性能优化
Running_slave7 小时前
你应该了解的TCP滑窗
前端·网络协议·tcp/ip
程序员小寒7 小时前
前端高频面试题之CSS篇(一)
前端·css·面试·css3
颜酱7 小时前
Monorepo 架构以及工具选型、搭建
前端·javascript·node.js