next7主题添加背景,并设置页面透明度

此文背景

因为自己最近愈来愈觉得简约美,于是决定取消网站的3D雪花特效,并且把背景图设置为护眼色,开干

声明配置项

  • 进入 blog/themes/next-7.7/_config.yml
  • 按住 command + f 搜索 custom_file_path

按照提示修改配置:

  • 取消掉 style: source/_custom/custom.styl 的注释
  • blog/source/创建_custom/custom.styl (具体配置见定义)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    # Define custom file paths.
    # Create your custom files in site directory `source/_data` and uncomment needed files below.
    custom_file_path:
    #head: source/_data/head.swig
    #header: source/_data/header.swig
    #sidebar: source/_data/sidebar.swig
    #postMeta: source/_data/post-meta.swig
    #postBodyEnd: source/_data/post-body-end.swig
    #footer: source/_data/footer.swig
    #bodyEnd: source/_data/body-end.swig
    #variable: source/_data/variables.styl
    #mixin: source/_data/mixins.styl
    # style: source/_data/styles.styl
    # 背景图片,以及板块透明等操作
    style: source/_custom/custom.styl

定以配置项

blog/source/_custom/custom.styl添加内容如下

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
// 设置背景图片
body {
// 使用网上动态变化的图片
// background:url(https://source.unsplash.com/random/1600x900); //这一行的括号里填背景图片的路径,将图片重命名为background.jpg放在\themes\next\source\images下
background-image:url(/images/background.png); //这一行的括号里填背景图片的路径,将图片重命名为background放在\themes\next7.7\source\images下
background-repeat: no-repeat;
background-attachment:fixed;
background-position:50% 50%;
background-size:100% 100%;
}

// 各板块设置透明度
// 侧边框的透明度设置
.content-wrap {
opacity: 0.75;
}

// 主板块
.main-inner {
background-color: rgba(255, 255, 255, 0);
}

// 主版块里的post板块(f12,cmd+shift+c找出)
.post-block {
opacity: 0.75;
}

// 侧边框的透明度设置
.sidebar {
opacity: 0.75;
}

// 菜单栏的透明度设置
.header-inner {
background: rgba(255, 255, 255, 0.75);
}

// 页码
.pagination {
opacity: 0.75;
}

// 搜索框(local-search)的透明度设置
.popup {
opacity: 0.75;
}

使用配置项

测试吧,少年
hexo clean && hexo g && hexo s

没问题就部署吧
hexo clean && hexo g && hexo deploy