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>

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

相关推荐
今天又在摸鱼几秒前
学习vue前必要的js语法
前端·vue.js·学习
大家的林语冰30 分钟前
TypeScript 6 官宣,JS “最后之舞“,版本升级踩雷指南
前端·javascript·typescript
英俊潇洒美少年32 分钟前
react useDeferredvalue和useTransition的讲解
前端·react.js·前端框架
爱学习的程序媛36 分钟前
【WebRTC】呼叫中心前端技术选型:SIP.js vs JsSIP vs Verto
前端·javascript·typescript·音视频·webrtc·实时音视频·web
Amumu1213844 分钟前
Js: ES新特性(一)
开发语言·前端·javascript
scofield_gyb44 分钟前
Redis 6.2.7安装配置
前端·数据库·redis
木斯佳1 小时前
前端八股文面经大全: 蓝色光标前端一面OC(2026-03-23)·面经深度解析
前端·面试·vue·校招·js·面经
2301_792580001 小时前
Pyrocko + PSGRN/PSCMP小问题
前端
Highcharts.js1 小时前
Highcharts for Python|用 Pythonic 的方式构建AI数据可视化图表
前端·人工智能·python·信息可视化·数据科学·highcharts·ai可视化
是罐装可乐1 小时前
SPA首屏接口过多导致卡顿?一套前端请求调度方案彻底解决
前端·性能优化·spa·前端架构·请求队列