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>

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

相关推荐
treesforest12 分钟前
前端表单提效实践:基于IP地理位置实现国家区号智能预填
前端·网络协议·tcp/ip·ip定位·ip属地
用户2986985301413 分钟前
React 中 Word 文档转图片的实践方案
前端·javascript·react.js
Csvn14 分钟前
异步并发控制:手写并发池、竞态防护与取消的完整方案
前端·javascript
csuzhucong15 分钟前
二十一 - 四十阶魔方
javascript·css·html
专业抄代码选手22 分钟前
06|双缓冲与 Commit:让 Fiber 支持第二次渲染
前端·javascript·react.js
涛涛ing22 分钟前
4.8K Star!一套规则让 AI 帮你写出“像人写的”前端代码
前端
万物智能25 分钟前
OpenHarmony源码树解剖—【万物智能之开源鸿蒙OpenHarmony系统实战开发系列教程】
前端·后端
天才熊猫君28 分钟前
通用虚拟滚动表格行拖拽排序:从思路到完整实现
前端·javascript
hh95030 分钟前
Agent Plan × DeepSeek Harness:角色 Prompt 驱动的 Agent 分工优化与协作质量实验
java·前端·人工智能·prompt·adg·agent plan·adg成都社区
专业抄代码选手33 分钟前
05|把递归渲染拆成 Fiber:让一棵大树可以暂停
前端·javascript·react.js