前言
博客开启黑夜模式以后为大标题和个人卡片添加霓虹灯特效
添加代码
打开Blog根目录/source/css/custom.css,路径中缺少的文件夹或文件直接创建即可,写入下列代码
可以把‘—theme-color’修改为你喜欢的颜色,例如墨绿色:rgb(91,165,133)
1 2 3 4 5 6 7 8 9 10
| [data-theme="dark"] #nav .site-page, [data-theme="dark"] #nav .menus_items .menus_item .menus_item_child li a { text-shadow: 0 0 2px var(--theme-color) !important; }
[data-theme="dark"] #sidebar #sidebar-menus .menus_items .site-page { text-shadow: 0 0 2px var(--theme-color) !important; }
|
新建脚本文件
打开Blog根目录\source\js\light.js,路径中缺少的文件夹或文件直接创建即可,写入下列代码
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
|
var arr = ["#39c5bb", "#f14747", "#f1a247", "#f1ee47", "#b347f1", "#1edbff", "#ed709b", "#5636ed"];
var idx = 0;
function changeColor() { if (document.getElementsByTagName('html')[0].getAttribute('data-theme') == 'dark') { if (document.getElementById("site-name")) document.getElementById("site-name").style.textShadow = arr[idx] + " 0 0 15px"; if (document.getElementById("site-title")) document.getElementById("site-title").style.textShadow = arr[idx] + " 0 0 15px"; if (document.getElementById("site-subtitle")) document.getElementById("site-subtitle").style.textShadow = arr[idx] + " 0 0 10px"; if (document.getElementById("post-info")) document.getElementById("post-info").style.textShadow = arr[idx] + " 0 0 5px"; try { document.getElementsByClassName("author-info__name")[0].style.textShadow = arr[idx] + " 0 0 12px"; document.getElementsByClassName("author-info__description")[0].style.textShadow = arr[idx] + " 0 0 12px"; } catch { } idx++; if (idx == 8) { idx = 0; } } else { if (document.getElementById("site-name")) document.getElementById("site-name").style.textShadow = "#1e1e1ee0 1px 1px 1px"; if (document.getElementById("site-title")) document.getElementById("site-title").style.textShadow = "#1e1e1ee0 1px 1px 1px"; if (document.getElementById("site-subtitle")) document.getElementById("site-subtitle").style.textShadow = "#1e1e1ee0 1px 1px 1px"; if (document.getElementById("post-info")) document.getElementById("post-info").style.textShadow = "#1e1e1ee0 1px 1px 1px"; try { document.getElementsByClassName("author-info__name")[0].style.textShadow = ""; document.getElementsByClassName("author-info__description")[0].style.textShadow = ""; } catch { } } }
window.onload = setInterval(changeColor, 1200);
|
引入文件
打开主题配置文件_config.butterfly.yml,搜索inject并按下列格式补充完整
1 2 3 4 5
| inject: head: - <link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"> bottom: - <script defer src="/js/light.js"></script>
|
hexo三连查看效果
1
| hexo cl && hexo g && hexo s
|