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>

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

相关推荐
kooboo china.18 分钟前
Tailwind CSS实战技巧:从核心类到高效开发
前端·javascript·css·编辑器·html
卓怡学长18 分钟前
w317汽车维修预约服务系统设计与实现
java·前端·spring boot·spring·汽车
lilye661 小时前
精益数据分析(38/126):SaaS模式的流失率计算优化与定价策略案例
前端·人工智能·数据分析
5:001 小时前
Qt:(创建项目)
java·前端·qt
green_pine_1 小时前
CSS学习笔记12——CSS3新增特性
前端·css·笔记·学习
Wenhao.1 小时前
Go-web开发之帖子功能
开发语言·前端·golang
蓝婷儿2 小时前
前端面试每日三题 - Day 22
前端·面试·职场和发展
java1234_小锋2 小时前
如何配置NGINX作为反向代理服务器来缓存后端服务的响应?
前端·nginx·缓存
A_aspectJ2 小时前
【Bootstrap V4系列】学习入门教程之 表格(Tables)和画像(Figure)
前端·bootstrap·dreamweaver
同聘云2 小时前
腾讯云web服务器配置步骤是什么?web服务器有什么用途?
服务器·前端·腾讯云