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>

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

相关推荐
IT_陈寒36 分钟前
React性能优化实战:这5个Hooks技巧让我的应用快了40%
前端·人工智能·后端
江天澄1 小时前
HTML5 中常用的语义化标签及其简要说明
前端·html·html5
知识分享小能手1 小时前
jQuery 入门学习教程,从入门到精通, jQuery在HTML5中的应用(16)
前端·javascript·学习·ui·jquery·html5·1024程序员节
2501_918126911 小时前
用html5写一个打巴掌大赛
css·css3·html5
美摄科技1 小时前
H5短视频SDK,赋能Web端视频创作革命
前端·音视频
常常不爱学习1 小时前
Vue3 + TypeScript学习
开发语言·css·学习·typescript·html
黄毛火烧雪下1 小时前
React Native (RN)项目在web、Android和IOS上运行
android·前端·react native
fruge1 小时前
前端正则表达式实战合集:表单验证与字符串处理高频场景
前端·正则表达式
baozj2 小时前
🚀 手动改 500 个文件?不存在的!我用 AST 撸了个 Vue 国际化神器
前端·javascript·vue.js
用户4099322502122 小时前
为什么Vue 3的计算属性能解决模板臃肿、性能优化和双向同步三大痛点?
前端·ai编程·trae