音波效果(纯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>
相关推荐
brzhang4 小时前
我操,终于有人把 AI 大佬们 PUA 程序员的套路给讲明白了!
前端·后端·架构
止观止5 小时前
React虚拟DOM的进化之路
前端·react.js·前端框架·reactjs·react
goms5 小时前
前端项目集成lint-staged
前端·vue·lint-staged
谢尔登5 小时前
【React Natve】NetworkError 和 TouchableOpacity 组件
前端·react.js·前端框架
Lin Hsüeh-ch'in5 小时前
如何彻底禁用 Chrome 自动更新
前端·chrome
augenstern4167 小时前
HTML面试题
前端·html
张可7 小时前
一个KMP/CMP项目的组织结构和集成方式
android·前端·kotlin
G等你下课7 小时前
React 路由懒加载入门:提升首屏性能的第一步
前端·react.js·前端框架
蓝婷儿8 小时前
每天一个前端小知识 Day 27 - WebGL / WebGPU 数据可视化引擎设计与实践
前端·信息可视化·webgl
然我8 小时前
面试官:如何判断元素是否出现过?我:三种哈希方法任你选
前端·javascript·算法