hugo搭建博客(三)
Featured image of post hugo搭建博客(三)

hugo搭建博客(三)

Hugo-theme-Stack 魔改美化

Avatar 😎

# 目录

# Hugo-theme-Stack 魔改美化

# 全局

# 零碎玩意

/assets/scss/custom.scss 中加入以下代码:

 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
// 页面基本配色
:root {
  // 全局顶部边距
  --main-top-padding: 30px;
  // 全局卡片圆角
  --card-border-radius: 25px;
  // 标签云卡片圆角
  --tag-border-radius: 8px;
  // 卡片间距
  --section-separation: 40px;
  // 全局字体大小
  --article-font-size: 1.8rem;
  // 行内代码背景色
  --code-background-color: #f8f8f8;
  // 行内代码前景色
  --code-text-color: #e96900;
  // 暗色模式下样式
  &[data-scheme="dark"] {
    // 行内代码背景色
    --code-background-color: #ff6d1b17;
    // 行内代码前景色
    --code-text-color: #e96900;
  }
}
...

(CSS代码省略,根据实际情况添加)

# 菜单栏圆角

/assets/scss/custom.scss 中加入以下代码:

1
2
3
4
5
6
// 菜单栏样式
// 下拉菜单改圆角样式
.menu {
  ...
}
...

(CSS代码省略,根据实际情况添加)

# 滚动条

/assets/scss/custom.scss 中加入以下代码:

1
2
3
4
5
6
//将滚动条修改为圆角样式
//菜单滚动条美化
.menu::-webkit-scrollbar {
  ...
}
...

(CSS代码省略,根据实际情况添加)

# 加载进度条

/layouts/partials/footer/custom.html 中加入以下代码:

1
2
3
4
5
6
7
8
9
<script src="https://npm.elemecdn.com/nprogress@0.2.0/nprogress.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://npm.elemecdn.com/nprogress@0.2.0/nprogress.css" crossorigin="anonymous" />
<script>
  NProgress.start();
  document.addEventListener("readystatechange", function() {
    if (document.readyState === "interactive") NProgress.inc(0.8);
    if (document.readyState === "complete") NProgress.done();
  });
</script>

(JS代码省略,根据实际情况添加)

# 细节

# 首页欢迎横幅

/layouts/index.html<section class="article-list"> 前添加以下代码:

1
2
3
4
5
6
7
8
9
<!-- 首页欢迎字幅 -->
<div class="welcome">
  <p style="font-size: 2rem; text-align: center; font-weight: bold">
    <span class="shake">👋</span>
    <span class="jump-text1">Welcome</span>
    ...
  </p>
</div>
<!-- 首页欢迎字幅 -->

(HTML代码省略,根据实际情况添加)

# 代码块

# macOS 风格红绿灯图标

/assets/scss/custom.scss 中加入以下代码:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// macOS 风格代码块
.article-content {
  .highlight:before {
    content: '';
    display: block;
    background: url(/code-header.svg);
    ...
  }
}
...

(CSS代码省略,根据实际情况添加)

# 键盘样式

/assets/scss/custom.scss 中加入以下代码:

1
2
3
4
5
// 键盘样式
kbd {
  ...
}
...

(CSS代码省略,根据实际情况添加)

# 头像旋转

/assets/scss/custom.scss 中加入以下代码:

1
2
3
4
5
6
7
8
// 头像旋转动画
.sidebar header .site-avatar .site-logo {
  ...
}
.sidebar header .site-avatar .site-logo:hover {
  ...
}
...

(CSS代码省略,根据实际情况添加)

# 鸣谢

  • Stack 主题文档
  • L1nSn0w
  • 小骆同学1 小骆同学2
  • Echosec
似水年华 - Licensed under CC BY-NC-SA 4.0

正在加载一言...

使用 Hugo 构建
主题 StackJimmy 设计
本博客已稳定运行