Fluid-7-添加星系loading动画

Hexo博客主题为Fluid

1.在themes\fluid\layout\_partials\路径下创建loading.ejs,内容参考:

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
<%
play_time=theme.loading.play_time || 500
%>

<style type="text/css">
@keyframes spin3D {
from {
transform: rotate3d(0.5, 0.5, 0.5, 360deg);
}

to {
transform: rotate3d(0deg);
}
}

#loading {
height: 100%;
background-color: #172d4781;
backdrop-filter: saturate(100%) blur(10px);
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
overflow: hidden;
z-index: 99999999;
}

.spinner-box {
width: 300px;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
background-color: transparent;
}

.leo {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}

.blue-orbit {
width: 175px;
height: 175px;
border: 2px solid #1a91fa;
animation: spin3D 3s linear .2s infinite;
}

.green-orbit {
width: 135px;
height: 135px;
border: 2px solid #00ffdd;
animation: spin3D 2s linear 0s infinite;
}

.red-orbit {
width: 100px;
height: 100px;
border: 2px solid #d75151;
animation: spin3D 1s linear 0s infinite;
}

.white-orbit-a {
width: 70px;
height: 70px;
border: 1px solid #faf5f5;
animation: spin3D 3s linear 0s infinite;
}

.white-orbit-b {
width: 70px;
height: 70px;
border: 1px solid #faf5f5;
animation: spin3D 1.5s linear 0s infinite;
}

.nucleus {
width: 1px;
height: 1px;
border: 1px solid #ffffff;
animation: spin3D 1s linear 0s infinite;
}
</style>

<div id="loading">
<div class="spinner-box">
<div class="blue-orbit leo"></div>
<div class="green-orbit leo"></div>
<div class="red-orbit leo"></div>
<div class="white-orbit-a leo"></div>
<div class="white-orbit-b leo"></div>
<div class="nucleus leo"></div>
</div>
</div>

<script>
(function () {
const loaded = function () {
window.onload = function () {
const loader = document.getElementById("loading");
loader.className = "fadeout";
setTimeout(function () {
loader.style.display = "none";
},
<%- play_time %>
);
}
};
loaded();
})();
</script>

2.修改themes\fluid\layout\layout.ejs文件,找到<body>标签,在其内部第一行插入下面代码:

1
2
3
<% if (theme.loading.enable) { %>
<%- partial('_partials/loading.ejs') %>
<% } %>

3.修改主题配置文件_config.fluid.yml,添加loading动画的配置项:

1
2
3
4
5
# 加载动画
loading:
enable: true
# 动画时长,从动画开始播放计算,不包含页面加载时间,单位ms
play_time: 500

觉得不错的话,支持一根棒棒糖吧 ୧(๑•̀⌄•́๑)૭



wechat pay



alipay

Fluid-7-添加星系loading动画
http://yuting0907.github.io/posts/58ed6977.html
作者
Echo Yu
发布于
2025年1月15日
许可协议