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>

教学视频地址

点击跳转教学视频

相关推荐

  1. CSS实现文字呼吸灯效果

    2023-12-27 12:56:01       46 阅读
  2. 编织文字的魔法:探索WebKit的CSS文本效果

    2023-12-27 12:56:01       26 阅读
  3. css实现文字左右循环滚动播放效果

    2023-12-27 12:56:01       42 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-27 12:56:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-27 12:56:01       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-27 12:56:01       82 阅读
  4. Python语言-面向对象

    2023-12-27 12:56:01       91 阅读

热门阅读

  1. NPM简介与使用指南:打造前端开发的利器

    2023-12-27 12:56:01       63 阅读
  2. chrome去除安全设置

    2023-12-27 12:56:01       68 阅读
  3. 在css中如何实现表单验证效果

    2023-12-27 12:56:01       62 阅读
  4. 如何强制 App 在 iOS 后台不断开与融云的长连接?

    2023-12-27 12:56:01       84 阅读
  5. 活动运营常用的ChatGPT通用提示词模板

    2023-12-27 12:56:01       57 阅读
  6. modbus-tcp-rtu协议图表

    2023-12-27 12:56:01       42 阅读
  7. leetcode | go | 第600题 | 不含连续1的非负整数

    2023-12-27 12:56:01       65 阅读
  8. vue中的动态组件和混入

    2023-12-27 12:56:01       51 阅读
  9. 2023年腾讯云活动:2核2G4M轻量服务器3年540元

    2023-12-27 12:56:01       62 阅读
  10. 分布式信号量(Redis)

    2023-12-27 12:56:01       55 阅读
  11. Spring缓存注解@Cacheable、@CachePut、@CacheEvict

    2023-12-27 12:56:01       57 阅读