Butterfly主题美化-页面毛玻璃效果

一、基本设置

1、创建css文件

创建一个mycss.css文件移动到\themes\butterfly\source\css目录下。

2、引入

inject在的butterfly.yml中或者自定义的_config.butterfly.yml

按以下方式引入css文件,不管以上哪种方式都以下面代码方式引入

1
2
3
inject:
head:
- <link rel="stylesheet" href="/css/mycss.css">

二、美化

在创建的mycss.css文件中加入以下内容

1、所有页面毛玻璃效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*所有页面实现毛玻璃特效*/
#aside-content{
background: rgba(255,255,255,0);
}

#aside-content > .card-widget:first-child {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
}

#aside-content .card-widget {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
}

.layout > div:first-child:not(.recent-posts) {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
}

#recent-posts > .recent-post-item {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
}

2、标题栏毛玻璃效果

1
2
3
4
5
/*标题栏*/
#page-header.nav-visible #nav {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(50px);
}

3、搜索栏毛玻璃效果

1
2
3
4
5
6
7
8
9
10
/*搜索框美化*/
.search-dialog {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
border-radius: 0px;
}

#search-mask {
background: rgba(255,255,255,0);
}

4、手机端毛玻璃效果

1
2
3
4
5
6
7
8
9
/*手机端毛玻璃优化*/
#sidebar #sidebar-menus.open {
background: rgba(255,255,255,0.5);
backdrop-filter: blur(10px);
}

#sidebar #menu-mask {
background: rgba(255,255,255,0);
}

美化前后对比

6、页脚、滚动条美化

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
/* 页脚footer */
/* 渐变色滚动动画 */
@-webkit-keyframes Gradient {
0% {
background-position: 0 50%;
}

50% {
background-position: 100% 50%;
}

100% {
background-position: 0 50%;
}
}

@-moz-keyframes Gradient {
0% {
background-position: 0 50%;
}

50% {
background-position: 100% 50%;
}

100% {
background-position: 0 50%;
}
}

@keyframes Gradient {
0% {
background-position: 0 50%;
}

50% {
background-position: 100% 50%;
}

100% {
background-position: 0 50%;
}
}
#footer {
background: linear-gradient(-45deg, #ee7752, #ce3e75, #23a6d5, #23d5ab);
background-size: 400% 400%;
-webkit-animation: Gradient 10s ease infinite;
-moz-animation: Gradient 10s ease infinite;
animation: Gradient 10s ease infinite;
-o-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}

#footer:before {
background-color: rgba(0, 0, 0, 0);
}

#footer-wrap {
background-color: rgba(0, 0, 0, 0);
}

/* 滚动条 */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}

::-webkit-scrollbar-track {
background-color: rgba(73, 177, 245, 0.2);
border-radius: 2em;
}

::-webkit-scrollbar-thumb {
background-color: #49b1f5;
background-image: -webkit-linear-gradient(
45deg,
rgba(255, 255, 255, 0.4) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, 0.4) 50%,
rgba(255, 255, 255, 0.4) 75%,
transparent 75%,
transparent
);
border-radius: 2em;
}

::-webkit-scrollbar-corner {
background-color: transparent;
}

::-moz-selection {
color: #fff;
background-color: #49b1f5;
}

7、博客背景美化

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
@keyframes gradientBG {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
#web_bg {
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradientBG 15s ease infinite;
}



#web_bg {
background: -webkit-linear-gradient(
0deg,
rgba(247, 149, 51, 0.1) 0,
rgba(243, 112, 85, 0.1) 15%,
rgba(239, 78, 123, 0.1) 30%,
rgba(161, 102, 171, 0.1) 44%,
rgba(80, 115, 184, 0.1) 58%,
rgba(16, 152, 173, 0.1) 72%,
rgba(7, 179, 155, 0.1) 86%,
rgba(109, 186, 130, 0.1) 100%
);
background: -moz-linear-gradient(
0deg,
rgba(247, 149, 51, 0.1) 0,
rgba(243, 112, 85, 0.1) 15%,
rgba(239, 78, 123, 0.1) 30%,
rgba(161, 102, 171, 0.1) 44%,
rgba(80, 115, 184, 0.1) 58%,
rgba(16, 152, 173, 0.1) 72%,
rgba(7, 179, 155, 0.1) 86%,
rgba(109, 186, 130, 0.1) 100%
);
background: -o-linear-gradient(
0deg,
rgba(247, 149, 51, 0.1) 0,
rgba(243, 112, 85, 0.1) 15%,
rgba(239, 78, 123, 0.1) 30%,
rgba(161, 102, 171, 0.1) 44%,
rgba(80, 115, 184, 0.1) 58%,
rgba(16, 152, 173, 0.1) 72%,
rgba(7, 179, 155, 0.1) 86%,
rgba(109, 186, 130, 0.1) 100%
);
background: -ms-linear-gradient(
0deg,
rgba(247, 149, 51, 0.1) 0,
rgba(243, 112, 85, 0.1) 15%,
rgba(239, 78, 123, 0.1) 30%,
rgba(161, 102, 171, 0.1) 44%,
rgba(80, 115, 184, 0.1) 58%,
rgba(16, 152, 173, 0.1) 72%,
rgba(7, 179, 155, 0.1) 86%,
rgba(109, 186, 130, 0.1) 100%
);
background: linear-gradient(
90deg,
rgba(247, 149, 51, 0.1) 0,
rgba(243, 112, 85, 0.1) 15%,
rgba(239, 78, 123, 0.1) 30%,
rgba(161, 102, 171, 0.1) 44%,
rgba(80, 115, 184, 0.1) 58%,
rgba(16, 152, 173, 0.1) 72%,
rgba(7, 179, 155, 0.1) 86%,
rgba(109, 186, 130, 0.1) 100%
);
}