vue3 css模拟语音通话不同语音、正在加载等的效果

实现效果如下:


在不同的时间,显示不一样的效果(大小是一样的,截图时尺寸发生了变化)

具体实现代码如下:

js 复制代码
<script setup>
import {ref} from "vue";

const max_hight = ref('40px')
const min_hight = ref('2px')
</script>

<template>
  <div class="loading loading-2">
    <ul>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
    </ul>
  </div>
</template>

<style scoped>
* {
  padding: 0;
  margin: 0;
  list-style: none;
}

.loading {
  width: 300px;
  height: v-bind(max_hight);
  margin: 100px auto;
}

.loading ul {
  height: v-bind(max_hight);
  width: 65px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.loading ul li {
  margin: 0 2px;
  width: 3px;
  height: v-bind(max_hight);
  background-color: darkgrey;
}

/* 1) 定义动画 */
@keyframes ani-height {
  0% {
    height: v-bind(max_hight);
  }

  50% {
    height: v-bind(min_hight);
  }

  100% {
    height: v-bind(max_hight);
  }
}

/* 2) 使用动画 */
li:nth-child(1) {
  animation: ani-height .5s .1s linear infinite;
}

li:nth-child(2) {
  animation: ani-height .5s .05s linear infinite;
}

li:nth-child(3) {
  animation: ani-height .5s .2s linear infinite;
}

li:nth-child(4) {
  animation: ani-height .5s .25s linear infinite;
}

li:nth-child(5) {
  animation: ani-height .5s .15s linear infinite;
}
</style>

其实主要的差别就是在不同时刻,将其高度设置成不一样的大小即可,也就是对动画的时间进行逐步后移即可

相关推荐
Wect9 分钟前
从输入URL到页面显示的完整技术流程
前端·面试·浏览器
没有bug.的程序员22 分钟前
自动化测试之魂:Selenium 与 TestNG 深度集成内核、Page Object 模型实战与 Web UI 交付质量指南
前端·自动化测试·selenium·ui·testng·page·object
夕除35 分钟前
js--22
前端·javascript·python
南雨北斗1 小时前
TypeScript 配置文件 `tsconfig.json`
前端
木斯佳1 小时前
前端八股文面经大全:万兴科技前端实习一面(2026-2-3)·面经深度解析
前端·科技
yuki_uix1 小时前
别让 AI 骗了:这些状态管理工具真的适合你吗?
前端·ai编程
日月云棠1 小时前
UE5 打包后 EXE 程序单实例的两种实现方法
前端·c++
滕青山1 小时前
Base64编码/解码 核心JS实现
前端·javascript·vue.js
Novlan12 小时前
@tdesign/uniapp 常见问题
前端
sww_10262 小时前
SAA ReactAgent工作原理
开发语言·前端·javascript