<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>纯CSS3抖动的音箱特效</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(135deg, #1a1a2e, #16213e);
margin: 0;
font-family: Arial, sans-serif;
overflow: hidden;
}
.speaker-set {
display: flex;
gap: 50px;
}
.speaker {
position: relative;
width: 150px;
height: 250px;
background: #333;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
animation: speaker-shake 0.1s infinite alternate;
}
.speaker::before {
content: '';
position: absolute;
width: 120px;
height: 120px;
background: radial-gradient(circle, #444 0%, #222 70%);
border-radius: 50%;
top: 30px;
left: 15px;
box-shadow: inset 0 0 15px rgba(0,0,0,0.8);
}
.speaker::after {
content: '';
position: absolute;
width: 80px;
height: 80px;
background: radial-gradient(circle, #555 0%, #333 70%);
border-radius: 50%;
top: 50px;
left: 35px;
}
.sound-waves {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.wave {
position: absolute;
width: 10px;
height: 5px;
background: rgba(255,255,255,0.3);
border-radius: 5px;
animation: sound-wave 1s infinite;
}
.wave:nth-child(1) {
top: 40px;
left: -20px;
animation-delay: 0.1s;
}
.wave:nth-child(2) {
top: 60px;
left: -20px;
animation-delay: 0.3s;
}
.wave:nth-child(3) {
top: 80px;
left: -20px;
animation-delay: 0.5s;
}
.wave:nth-child(4) {
top: 100px;
left: -20px;
animation-delay: 0.7s;
}
.wave:nth-child(5) {
top: 120px;
left: -20px;
animation-delay: 0.9s;
}
.wave:nth-child(6) {
top: 40px;
right: -20px;
animation-delay: 0.1s;
}
.wave:nth-child(7) {
top: 60px;
right: -20px;
animation-delay: 0.3s;
}
.wave:nth-child(8) {
top: 80px;
right: -20px;
animation-delay: 0.5s;
}
.wave:nth-child(9) {
top: 100px;
right: -20px;
animation-delay: 0.7s;
}
.wave:nth-child(10) {
top: 120px;
right: -20px;
animation-delay: 0.9s;
}
.stand {
position: absolute;
width: 30px;
height: 20px;
background: #222;
bottom: -20px;
left: 60px;
border-radius: 0 0 5px 5px;
}
@keyframes speaker-shake {
0% {
transform: translateX(0) translateY(0);
}
100% {
transform: translateX(1px) translateY(1px);
}
}
@keyframes sound-wave {
0% {
transform: scaleX(0.5);
opacity: 0;
}
50% {
transform: scaleX(3);
opacity: 0.5;
}
100% {
transform: scaleX(0.5);
opacity: 0;
}
}
/* 插入的链接样式 */
.custom-link {
position: fixed;
bottom: 20px;
right: 20px;
color: rgba(255,255,255,0.7);
text-decoration: none;
font-size: 14px;
background: rgba(0,0,0,0.3);
padding: 8px 15px;
border-radius: 20px;
transition: all 0.3s ease;
}
.custom-link:hover {
color: white;
background: rgba(0,0,0,0.5);
}
</style>
</head>
<body>
<div class="speaker-set">
<div class="speaker">
<div class="sound-waves">
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
</div>
<div class="stand"></div>
</div>
<div class="speaker">
<div class="sound-waves">
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
</div>
<div class="stand"></div>
</div>
</div>
</body>
</html>