前言

自从创建了博客,沉迷于各种魔改美化无法自拔

这里记录几个今天做的修改

以防以后我不知道都改了什么orz

背景修改

统一顶部图和背景图

一直想搞个全局都一样的背景,不过搜来搜去改来改去都不是想要的样子

不过倒是在B站上找到了想要的实现

总之就是在_config.yml文件中把index_img和wb的background改成一样的就行了

1
2
3
4
5
6
7
# The banner image of home page
index_img: https://pic3.zhimg.com/v2-5e64bd671540888a614aa0b1ff74161a_r.jpg

.........

# Website Background (設置網站背景)
background: url(https://pic3.zhimg.com/v2-5e64bd671540888a614aa0b1ff74161a_r.jpg)

主页背景透明

在自建的CSS文件中修改,改好后需要将这个css文件按照根目录地址填写到配置文件的inject里

1
2
3
4
5
6
7
#page-header:not(.not-top-img):before {
position: absolute;
width: 100%;
height: 100%;
background-color: rgb(0,0,0,0); //透明度调为0就行了
content: '';
}

卡片及文章页透明化

加入,调整alpha即可

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
#page-header {
position: relative;
width: 100%;
background-color: #f5494900;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
-ms-transition: all 0.5s;
transition: all 0.5s;
}
.cardHover, .layout > div:first-child:not(.recent-posts), #recent-posts > .recent-post-item, #aside-content .card-widget, .layout > .recent-posts .pagination > *:not(.space) {
border-radius: 8px;
background: rgb(255 255 255 / 80%);
-webkit-box-shadow: var(--card-box-shadow);
box-shadow: var(--card-box-shadow);
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}

字体颜色

因为背景透明度调整为0了,所以的调整一下博客标题的颜色,同样的位置插入:

1
2
3
4
5
6
7
8
9
#page-header #site-title {
margin: 0;
color: #6a669f;
font-size: 1.85em;
}
#page-header #site-subtitle {
color: #3d2281ad;
font-size: 1.15em;
}

其实想改啥直接F12看着改,改完觉得不错把那一段加进来就行了

特效添加

页脚养鱼

在配置文件的inject中加入

1
2
3
bottom:
- <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
- <script src="https://cdn.jsdelivr.net/gh/xiabo2/CDN@latest/fishes.js"></script>

首页水波

自建一个js文件,添加

1
2
3
4
5
6
7
8
9
10
11
12
/* 水波荡漾 */
$(document).ready(function () {
try {
$("#page-header").ripples({
resolution: 512,
dropRadius: 10, //px
perturbance: 0.01,
});
} catch (e) {
$(".error").show().text(e);
}
});

inject里添加:

1
2
bottom:
- <script src="js地址"></script>

漂浮的花瓣

同样的方法,在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
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
var stop, staticx;
var img = new Image();
img.src = 'https://pic.dogimg.com/2022/04/12/6254fed76ed6b.png'

function Sakura(x, y, s, r, fn) {
this.x = x;
this.y = y;
this.s = s;
this.r = r;
this.fn = fn;
}
Sakura.prototype.draw = function (cxt) {
cxt.save();
var xc = 40 * this.s / 4;
cxt.translate(this.x, this.y);
cxt.rotate(this.r);
cxt.drawImage(img, 0, 0, 80 * this.s, 80 * this.s)
cxt.restore();
}
Sakura.prototype.update = function () {
this.x = this.fn.x(this.x, this.y);
this.y = this.fn.y(this.y, this.y);
this.r = this.fn.r(this.r);
if (this.x > window.innerWidth || this.x < 0 || this.y > window.innerHeight || this.y < 0) {
this.r = getRandom('fnr');
if (Math.random() > 0.4) {
this.x = getRandom('x');
this.y = 0;
this.s = getRandom('s');
this.r = getRandom('r');
} else {
this.x = window.innerWidth;
this.y = getRandom('y');
this.s = getRandom('s');
this.r = getRandom('r');
}
}
}
SakuraList = function () {
this.list = [];
}
SakuraList.prototype.push = function (sakura) {
this.list.push(sakura);
}
SakuraList.prototype.update = function () {
for (var i = 0, len = this.list.length; i < len; i++) {
this.list[i].update();
}
}
SakuraList.prototype.draw = function (cxt) {
for (var i = 0, len = this.list.length; i < len; i++) {
this.list[i].draw(cxt);
}
}
SakuraList.prototype.get = function (i) {
return this.list[i];
}
SakuraList.prototype.size = function () {
return this.list.length;
}

function getRandom(option) {
var ret, random;
switch (option) {
case 'x':
ret = Math.random() * window.innerWidth;
break;
case 'y':
ret = Math.random() * window.innerHeight;
break;
case 's':
ret = Math.random();
break;
case 'r':
ret = Math.random() * 6;
break;
case 'fnx':
random = -0.5 + Math.random() * 1;
ret = function (x, y) {
return x + 0.5 * random - 1.7;
};
break;
case 'fny':
random = 1.5 + Math.random() * 0.7
ret = function (x, y) {
return y + random;
};
break;
case 'fnr':
random = Math.random() * 0.03;
ret = function (r) {
return r + random;
};
break;
}
return ret;
}

function startSakura() {
requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame;
var canvas = document.createElement('canvas'),
cxt;
staticx = true;
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
canvas.setAttribute('style', 'position: fixed;left: 0;top: 0;pointer-events: none;');
canvas.setAttribute('id', 'canvas_sakura');
document.getElementsByTagName('body')[0].appendChild(canvas);
cxt = canvas.getContext('2d');
var sakuraList = new SakuraList();
for (var i = 0; i < 50; i++) {
var sakura, randomX, randomY, randomS, randomR, randomFnx, randomFny;
randomX = getRandom('x');
randomY = getRandom('y');
randomR = getRandom('r');
randomS = getRandom('s');
randomFnx = getRandom('fnx');
randomFny = getRandom('fny');
randomFnR = getRandom('fnr');
sakura = new Sakura(randomX, randomY, randomS, randomR, {
x: randomFnx,
y: randomFny,
r: randomFnR
});
sakura.draw(cxt);
sakuraList.push(sakura);
}
stop = requestAnimationFrame(function () {
cxt.clearRect(0, 0, canvas.width, canvas.height);
sakuraList.update();
sakuraList.draw(cxt);
stop = requestAnimationFrame(arguments.callee);
})
}
window.onresize = function () {
var canvasSnow = document.getElementById('canvas_snow');
}
img.onload = function () {
startSakura();
}

function stopp() {
if (staticx) {
var child = document.getElementById("canvas_sakura");
child.parentNode.removeChild(child);
window.cancelAnimationFrame(stop);
staticx = false;
} else {
startSakura();
}
}

之后可以在这两个地方调整图像和大小

1
2
3
4
5
6
7
8
9
10
img.src = '图片地址'

Sakura.prototype.draw = function (cxt) {
cxt.save();
var xc = 40 * this.s / 4;
cxt.translate(this.x, this.y);
cxt.rotate(this.r);
cxt.drawImage(img, 0, 0, 你想要的大小 * this.s, 你想要的大小 * this.s)
cxt.restore();
}

结束语

一时魔改一时爽,一直魔改一直爽