页面预加载UI实现

页面circle加载动画

image-20241116165834762.png

HTML

1
2
3
4
<div class="container">
<div class="circle"></div>
<span>loding......</span>
</div>

CSS

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
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100vh;
/* border: 10px solid red; */
}
.container {
position: relative;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
/* border: 10px solid rgb(0, 132, 255); */
background-color: black;
}
/* 背景彩色圆圈 */
.circle {
position: absolute;
width: 200px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
/* border: 10px solid rgb(0, 255, 170); */
background-image: linear-gradient(
0deg,
rgb(0, 255, 170),
rgb(0, 17, 255),
rgb(255, 0, 255)
);
/* !!!动画!!! */
animation: rotate 2s linear infinite;
}
/* 模糊 */
.circle::before {
content: '';
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
/* border: 10px solid rgb(0, 255, 170); */
background-image: linear-gradient(
0deg,
rgb(0, 255, 170),
rgb(0, 17, 255),
rgb(255, 0, 255)
);
filter: blur(35px);
}
/* 黑圈 */
.circle::after {
content: '';
position: absolute;
width: 180px;
height: 180px;
border-radius: 50%;
background-color: black;
}
/* 文字 */
span {
position: absolute;
color: rgb(255, 255, 255);
}

重点

1
animation: rotate 2s linear infinite;
1
2
3
4
5
6
7
8
9
/* 动画 */
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}