
html
<span class="voice-wave">
<span class="voice-line"></span>
<span class="voice-line"></span>
<span class="voice-line"></span>
<span class="voice-line"></span>
<span class="voice-line"></span>
</span>
css
// 语音输入波浪动画
.voice-wave {
display: flex;
align-items: center;
justify-content: center;
padding: 0 5px;
.voice-line {
display: inline-block;
width: 2px;
height: 12px;
background-color: #3366FF;
margin: 0 1px;
border-radius: 2px;
animation: voice-pulse 1.2s infinite ease-in-out;
}
// 为每个线条设置不同的动画延迟,形成波浪效果
.voice-line:nth-child(1) {
animation-delay: 0s;
}
.voice-line:nth-child(2) {
animation-delay: 0.2s;
}
.voice-line:nth-child(3) {
animation-delay: 0.4s;
}
.voice-line:nth-child(4) {
animation-delay: 0.6s;
}
.voice-line:nth-child(5) {
animation-delay: 0.8s;
}
}
// 语音波浪动画定义
@keyframes voice-pulse {
0%,
100% {
height: 4px;
opacity: 0.3;
}
50% {
height: 16px;
opacity: 1;
}
}