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>

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

相关推荐
涂山小楼15 小时前
线程join()方法的深度理解
java·前端·算法
烈焰飞鸟15 小时前
华为云前后端部署实战手册
运维·前端·vue.js·后端·华为云
挨踢攻城15 小时前
Linux 下合并多个 PDF 文件为一个 PDF 文件的方法
linux·前端·rhce·rhca·linux运维·红帽认证·公众号:厦门微思网络
怕浪猫15 小时前
React从入门到出门第三章 虚拟 DOM 与并发渲染基础
前端·javascript·react.js
wniuniu_15 小时前
ceph的osd
java·前端·ceph
他是龙55115 小时前
55:XSS防御机制与绕过实战(CSP+HttpOnly+Filter)
前端·chrome·xss
名誉寒冰15 小时前
基于 React + Three.js + 大模型的全息地球 Web 项目(水个web课程设计)
前端·javascript·react.js·ai编程
CodeSheep15 小时前
Linux再添一员猛将,操作完全不输Windows!
前端·后端·程序员
xingzhemengyou115 小时前
LINUX modprobe 智能加载和卸载内核模块
linux·服务器·前端