纯CSS文本Loading动画

效果预览

源码

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="zh">

<head>
<meta charset="UTF-8">
<title>纯CSS文本Loading动画</title>
<style>
body {
height: 100vh;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
background-color: #333;
}

.loader {
width: 30em;
height: 3em;
color: #fff;
font-size: 1.5em;
font-family: sans-serif;
text-transform: uppercase;
position: relative;
animation: change-color 10s linear infinite;
}

@keyframes change-color {

0%,
100% {
color: #419693;
}

33% {
color: #4fb7b4;
}

66% {
color: #93d6d0;
}
}

.loader span {
height: 3em;
position: absolute;
left: calc((var(--n) - 1) * 15%);
animation: moving 2s linear infinite;
animation-delay: calc((var(--n) - 10) * 0.2s);
}

@keyframes moving {
0% {
filter: opacity(0);
transform: rotate(-180deg);
left: 100%;
}

33% {
filter: opacity(1);
transform: rotate(0deg);
left: 60%;
}

66% {
filter: opacity(1);
transform: rotate(0deg);
left: 40%;
}

100% {
filter: opacity(0);
transform: rotate(180deg);
left: 0%;
}
}

.loader span:nth-child(1) {
--n: 1;
}

.loader span:nth-child(2) {
--n: 2;
}

.loader span:nth-child(3) {
--n: 3;
}

.loader span:nth-child(4) {
--n: 4;
}

.loader span:nth-child(5) {
--n: 5;
}

.loader span:nth-child(6) {
--n: 6;
}

.loader span:nth-child(7) {
--n: 7;
}

.font-l::before {
content: "l";
}

.font-o::before {
content: "o";
}

.font-a::before {
content: "a";
}

.font-d::before {
content: "d";
}

.font-i::before {
content: "i";
}

.font-n::before {
content: "n";
}

.font-g::before {
content: "g";
}
</style>
</head>

<body>
<div class="loader">
<span class="font-l"></span>
<span class="font-o"></span>
<span class="font-a"></span>
<span class="font-d"></span>
<span class="font-i"></span>
<span class="font-n"></span>
<span class="font-g"></span>
</div>
</body>

</html>