一、页面加载动画
🔗Hexo博客Fluid主题魔改记录 - KEVIN’S BLOG (kevinchu.top)
1. 基础配置步骤
- 创建
loading.ejs
文件于themes\fluid\layout\_partials\
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>
|
- 在
layout.ejs
的<body>
标签内首行插入:
1 2 3
| <% if (theme.loading.enable) { %> <%- partial('_partials/loading.ejs') %> <% } %>
|
2. 动画控制脚本
增加超过1s移除功能,需放于较前位置加载:
1 2 3 4
| setTimeout(() => { document.getElementById('loading').style.display = 'none'; }, 1000);
|
3. 主题配置项
修改主题配置文件_config.fluid.yml
,添加loading动画的配置项:
1 2 3 4 5
| loading: enable: true play_time: 500
|
二、全屏背景方案
1. 全屏背景固定方案
全屏背景:春草明年绿💔王孙归不归 (qingshaner.com)
- 创建
injector.js
:
1 2 3 4 5
| const { root: siteRoot = "/" } = hexo.config;
hexo.extend.injector.register("body_begin", `<div id="web_bg"></div>`);
hexo.extend.injector.register("body_end",`<script src="${siteRoot}js/backgroundize.js"></script>`);
|
- 背景控制脚本
backgroundize.js
:
1 2 3 4 5 6 7 8 9 10 11 12
| document .querySelector('#web_bg') .setAttribute('style', `background-image: ${document.querySelector('.banner').style.background.split(' ')[0]};position: fixed;width: 100%;height: 100%;z-index: -1;background-size: cover;`);
document .querySelector("#banner") .setAttribute('style', 'background-image: url()')
document .querySelector("#banner .mask") .setAttribute('style', 'background-color:rgba(0,0,0,0)')
|
2. 毛玻璃效果
- 透明背景
_config.fluid.yml
修改背景色为透明
1 2 3 4
|
board_color: "#ffffff80" board_color_dark: "#00000080"
|
2.毛玻璃滤镜
1 2 3 4 5
| css`文件夹新建`cloudedGlass.css #board { -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
|
3.引入css
_config.fluid.yml
引入
1 2 3 4
|
custom_css: - /css/cloudedGlass.css
|
参考链接:
《背景固定 (AIGISSS)》
https://blog.fufu.ink/2023/04/walinedecoration.html)
导航栏标题霓虹灯特效
修改themes\fluid\source\css\_pages\_base\_widget\header.styl
,在里面追加样式(注意缩进):
1 2 3 4 5 6 7 8 9 10 11
| .navbar-title outline none --c lightseagreen text-shadow 0 0 10px var(--c),0 0 20px var(--c),0 0 40px var(--c),0 0 80px var(--c),0 0 160px var(--c) animation animate 5s linear infinite
@keyframes animate{ to{ filter: hue-rotate(360deg) } }
|
然后修改themes\fluid\layout\_partials\header\navigation.ejs
,
找到对应导航栏标题的标签内容:
<strong><%= theme.navbar.blog_title || config.title %></strong>
给其添加上class属性,修改为:
<strong class="navbar-title"><%= theme.navbar.blog_title || config.title %></strong>