音波效果(纯CSS实现)

html 复制代码
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<!-- 移动端适配 -->
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- 引入VUE CDN -->
	<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
	<!-- 引入el样式 -->
	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
	<!-- 引入el组件库 -->
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
	<title>音波效果</title>
</head>
<style>

/*实现原理就是通过动画控制高度,距离顶部高度,背景色变换*/

	@keyframes soundWave {
  0%, 100% {
    height: 10%;
    margin-top: 25%;
    background: #f677b0;
  }
  50% {
    height: 100%;
    margin-top: 0%;
    background: #df7ff2;
  }
}

.music {
  width: 175px;
  height: 100px;
  display: flex;
  align-items: flex-end;
}

.music span {
  width: 6px;
  border-radius: 18px;
  margin-right: 6px;
  background: #f677b0;
  animation: soundWave 2s infinite linear;
}

.music span:nth-child(2) {
  animation-delay: 0.2s;
  background: #df7ff2;
}

.music span:nth-child(3) {
  animation-delay: 0.4s;
  background: #8c7ff2;
}

.music span:nth-child(4) {
  animation-delay: 0.6s;
  background: #7fd0f2;
}

.music span:nth-child(5) {
  animation-delay: 0.8s;
  background: #7ff2d3;
}

.music span:nth-child(6) {
  animation-delay: 1.0s;
  background: #7ff2a0;
}

.music span:nth-child(7) {
  animation-delay: 1.2s;
  background: #adf27f;
}

.music span:nth-child(8) {
  animation-delay: 1.4s;
  background: #e7f27f;
}

.music span:nth-child(9) {
  animation-delay: 1.6s;
  background: #ecaa64;
}
</style>

<body>
	<div id="app">

		<div class="music">
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
			<span></span>
		  </div>


	</div>
	<script>
		/* 实例化vue */
		var app = new Vue({
			el: '#app',
			data: {

			},
			mounted() {

			},
			methods: {



			}
		})
	</script>
</body>

</html>
相关推荐
申阳4 分钟前
Day 5:03. 基于Nuxt开发博客项目-页面结构组织
前端·后端·程序员
全马必破三12 分钟前
React的设计理念与核心特性
前端·react.js·前端框架
ttod_qzstudio18 分钟前
替代 TDesign Dialog:用 div 实现可拖拽、遮罩屏蔽的对话框
前端·tdesign
洞窝技术22 分钟前
前端人必看的 node_modules 瘦身秘籍:从臃肿到轻盈,Umi 项目依赖优化实战
前端·vue.js·react.js
Asort32 分钟前
React函数组件深度解析:从基础到最佳实践
前端·javascript·react.js
golang学习记33 分钟前
VS Code + Chrome DevTools MCP 实战:用 AI 助手自动分析网页性能
前端
用户40993225021235 分钟前
Vue 3中reactive函数如何通过Proxy实现响应式?使用时要避开哪些误区?
前端·ai编程·trae
Qinana40 分钟前
🌐 从 HTML/CSS/JS 到页面:浏览器渲染全流程详解
前端·程序员·前端框架
BBB努力学习程序设计42 分钟前
网页布局必备技能:手把手教你实现优雅的纵向导航
前端·html