0%

CSS3实现语音声波


RT。

项目需求中实现的一个css3样式写的语音录入效果。

wave

wave2

1
2
3
4
5
6
7
8
9
10
11
<view class="animation start">
<view
class="item"
v-for="(w, idx) in waveStart"
:class="'waveStart-' + w"
:key="idx"
></view>
<view class="item" v-for="(w, idx) in waveList" :class="'wave-' + w" :key="idx"></view>
<view class="item" v-for="(w, idx) in waveEnd" :class="'waveStart-' + w" :key="idx"></view>
</view>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// 时间
$frameTime: 0.5s;
.animation {
flex: 3;
display: flex;
gap: 10rpx;
align-items: center;
&.start {
.item {
animation-iteration-count: infinite;
animation-direction: alternate;
}
}
.item {
width: 8rpx;
background-color: rgba(58, 155, 255, 1);
transform: scale(0.6);
}
.waveStart-1 {
height: 20rpx;
animation: radius-start $frameTime ease;
}
.waveStart-2 {
height: 36rpx;
animation: radius-start $frameTime ease;
}
.waveStart-3 {
height: 52rpx;
animation: radius-start $frameTime ease;
}
.waveStart-4 {
height: 70rpx;
animation: radius-start $frameTime ease;
}

.wave-1 {
height: 8rpx;
animation: radius-animation-1 $frameTime ease;
}
.wave-2 {
height: 20rpx;
animation: radius-animation-2 $frameTime ease;
}
.wave-3 {
height: 36rpx;
animation: radius-animation-3 $frameTime ease;
}
.wave-4 {
height: 52rpx;
animation: radius-animation-4 $frameTime ease;
}
.wave-5 {
height: 70rpx;
animation: radius-animation-5 $frameTime ease;
}
}

@keyframes radius-start {
100% {
height: 8rpx;
}
}

@keyframes radius-animation-1 {
100% {
height: 90rpx;
}
}

@keyframes radius-animation-2 {
80% {
height: 80rpx;
}
100% {
height: 70rpx;
}
}
@keyframes radius-animation-3 {
60% {
height: 80rpx;
}
100% {
height: 52rpx;
}
}
@keyframes radius-animation-4 {
40% {
height: 80rpx;
}
100% {
height: 36rpx;
}
}
@keyframes radius-animation-5 {
20% {
height: 80rpx;
}
100% {
height: 20rpx;
}
}