跳到正文

科技·工程

使用github搭建自己的blog

StatTrak_TM约 7 分钟
原文
文章信息与版本

文章信息

发布
2025年5月11日
收录
2025年12月12日
更新
2026年11月15日
篇幅
约 7 分钟

版本

  1. v1当前

声明:作者不会 html,代码均由 AI 完成。

1. 准备

  • github 账号一个

2. 创建仓库

创建一个 github 仓库,名称是你的用户名.github.io。
点最下面绿色的按钮。
点 add file,creat new file, 在 name your file 处写 index.html,点 commit changes,这就是你的主页。
参考。

HTML
<!DOCTYPE html>
<html>
<head>
  <title>scratch_szc's blog</title>
</head>
<body>
 <body>
  <h1>scratch_szc's blog</h1>
  <div id="bottem"></div>
</body>
</html>

如何写博客? 还是点 add file,creat new file, 在 name your file 处写 blogs/test.md, 将 markdown 文件粘贴进去,点 commit changes,即可。等待一段时间后访问 你的 github 用户名.github.io/test 就能看到了。

3.美化

创建文件styles.css,写入如下代码:

CSS
/* ===== 浅色主题变量 ===== */
:root {
  --primary: #158D9A;        /* 柔和紫色 */
  --secondary: #2E86C1;      /* 浅海蓝色 */
  --text: #2C3E50;           /* 深灰蓝 */
  --background: #F9F9F9;     /* 浅灰背景 */
  --code-bg: #ECF0F1;        /* 代码块浅灰 */
  --border: #BDC3C7;         /* 中性浅灰 */
}

/* ===== 全局重置 ===== */
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--background);
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
}

/* ===== 标题系统 ===== */
h1{
  color: var(--primary);
  font-size: 2.5rem;
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--secondary);
}

h2 {
  color: var(--secondary);
  font-size: 1.8rem;
  margin: 2rem 0 1rem;
  border-bottom: 2px solid #D6EAF8;  /* 浅蓝色分隔线 */
  padding-bottom: 0.5rem;
}
h3 {
  color: #87CEEB;  /* 标准天蓝 */
  font-size: 1.4rem;
  border-bottom: 2px solid rgba(52,152,219,0.3);
  padding-bottom: 0.3rem;
  margin: 1.5rem 0;
}

h4 {
  color: #00BFFF;  /* 深天蓝 */
  font-size: 1.3rem;
  margin: 1.2rem 0;
}

h5 {
  color: #B0E0E6;  /* 浅天蓝 */
  font-size: 1.2rem;
  opacity: 0.9;
}

h6 {
  color: #87CEEB;
  font-size: 1.1rem;
  font-style: italic;
  opacity: 0.8;
}

/* ===== 内容区块 ===== */
.content-section {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* ===== 列表样式 ===== */
ul {
  list-style: none;
  padding-left: 1.5rem;
}

li {
  position: relative;
  margin: 0.8rem 0;
  padding-left: 1.2rem;
}

li::before {
  content: "•";
  color: var(--secondary);
  position: absolute;
  left: 0;
  font-size: 1.2rem;
}

/* ===== 代码区块 ===== */
pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--secondary);
  overflow-x: auto;
}

code {
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  color: #1A5276;  /* 深蓝代码文字 */
}

/* ===== 响应式优化 ===== */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }
  h1.title {
    font-size: 2rem;
  }
}

/* ===== 页脚样式 ===== */
footer {
  background: white;
  color: var(--text);
  text-align: center;
  padding: 1.5rem;
  margin-top: 3rem;
  border-top: 3px solid var(--secondary);
  box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}
/* ===== 超链接系统 ===== */
a {
  color: #87CEEB !important;          /* 标准天蓝色 */
  text-decoration: none;              /* 去除下划线 */
  background: linear-gradient(#3498db, #3498db) no-repeat 0 100%;
  background-size: 0 2px;             /* 蓝色下划线动效 */
  transition: color 0.3s, background-size 0.3s;
}
/* ===== 统一链接颜色 (深色主题适配) ===== */
a {
  color: #87CEEB !important;          /* 天蓝色覆盖所有状态 */
  text-decoration: none;
  transition: opacity 0.3s;
}

a:hover {
  opacity: 0.8 !important;            /* 悬停透明度变化 */
  text-decoration: underline;
}

a:visited,
a:active,
a:focus {
  color: #87CEEB !important;         /* 强制所有状态保持天蓝 */
}

保存,在index.html的<head>下加入<link rel="stylesheet" href="/assets/css/style.css">即可。

原文
存档评论1 条抓取于