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
150
151
152
153
154
|
<div class="loading">
<div class="sharingon">
<div class="ring">
<div class="to"></div>
<div class="to"></div>
<div class="to"></div>
<div class="circle"></div>
</div>
</div>
</div>
<style>
.loading {
position: fixed;
display: flex;
justify-content: center;
align-items: center;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99;
zoom: 3.0;
background-color: #f5f5fa;
}
.animated-stop {
animation-play-state: paused !important;
}
.scaleAndFadeout {
animation: scaleAndFadeOut 1.5s forwards;
}
/** 放大1.5倍,并渐变到透明 */
@keyframes scaleAndFadeOut {
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(1.5);
opacity: 0;
}
}
/* From Uiverse.io by shadowfax29 */
.sharingon {
position: relative;
width: 6em;
height: 6em;
background-color: red;
border: 6px solid black;
animation: rot 1s ease-in-out infinite;
}
.ring {
position: absolute;
content: "";
left: 50%;
top: 50%;
width: 3.5em;
height: 3.5em;
border: 4px solid rgb(110, 13 ,13 ,0.5);
transform: translate(-50%,-50%);
}
.sharingon, .ring, .to,.circle {
border-radius: 50%;
}
.to,.circle {
position: absolute;
content: "";
width: 0.9em;
height: 0.9em;
background-color: black;
}
.to:nth-child(1) {
top: -0.5em;
left: 50%;
transform: translate(-40%);
}
.to::before {
content: "";
position: absolute;
top: -0.5em;
right: -0.2em;
width: 1.1em;
height: 0.9em;
box-sizing: border-box;
border-left: 16px solid black;
border-radius: 100% 0 0;
}
.to:nth-child(2) {
bottom: 0.5em;
left: -0.35em;
transform: rotate(-120deg);
}
.to:nth-child(3) {
bottom: 0.5em;
right: -0.35em;
transform: rotate(120deg);
}
.circle {
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
box-shadow: 0 0 20px 1px;
width: 1em;
height: 1em;
}
@keyframes rot {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<script>
function initLoading() {
let loading = document.querySelector(".loading");
document.addEventListener('DOMContentLoaded', function() {
// 本地页面加载速度快,可自行使用setTimeout()来进行延迟,体验加载动画效果
// 执行加载完成动画
loadFinish();
// 延迟1.5s,待加载完成动画执行结束
setTimeout(() => {
loading.style.display = "none";
}, 1500)
});
}
function loadFinish() {
// 暂停动画
let sharingon= document.querySelector(".sharingon");
sharingon.classList.add("animated-stop")
// 放大并渐变到透明
let loading = document.querySelector(".loading");
loading.classList.add("scaleAndFadeout")
}
initLoading();
</script>
|