我的 CSS 设置

《如果你想使用这套 WordPress 主题》,最近更新了博客的 CSS 设置,分享给有需要的朋友。

整体设计以文字为主,少装饰性元素。不用颜色引导,而用灰阶节奏和留白。

ChatGPT 辅助设计,有问题可以帮忙反馈在评论区!

以下是完整 CSS:

html,
body {
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
  font-weight: 400;
  line-height: 1.6;
  color: #222;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background-color: #fff;
  margin: 0;
  padding: 0;
}

/* ---------- 桌面基础版 ---------- */
.entry-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  font-size: 1rem;
  line-height: 1.9;
  letter-spacing: 0.02em;
  color: #222;
  background-color: #fff;
  -webkit-font-smoothing: antialiased;
}

.entry-content p {
  margin: 1.2em 0;
  text-indent: 1em;
  word-break: break-word;
  overflow-wrap: break-word;
}

.entry-content h1 + p,
.entry-content h2 + p,
.entry-content h3 + p,
.entry-content h4 + p {
  text-indent: 0;
}

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
  font-weight: 500;
  line-height: 1.4;
  color: #000;
  letter-spacing: 0.01em;
  margin: 2.4em 0 1em;
  text-indent: 0;
}

.entry-content h1 {
  font-size: 1.6rem;
  text-align: center;
  line-height: 1.3;
  margin: 0 0 2rem;
  color: #000;
}

.entry-content h2 {
  font-size: 1.25rem;
  border-left: 3px solid #000;
  padding-left: 0.6em;
}

.entry-content h3 {
  font-size: 1.1rem;
  color: #444;
  border-left: 2px solid #aaa;
  padding-left: 0.6em;
}

.entry-content h4,
.entry-content h5,
.entry-content h6 {
  font-size: 1rem;
  color: #444;
  border-left: none;
  padding-left: 0;
  margin-top: 2em;
}

/* 链接 */
.entry-content a {
  color: #555;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-skip-ink: auto;
  transition: color 0.2s ease, text-underline-offset 0.2s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.entry-content a:hover,
.entry-content a:focus-visible {
  color: #000;
  text-underline-offset: 4px;
  outline: none;
}
.entry-content a:focus-visible {
  background-color: rgba(0,0,0,0.03);
}

/* 列表 */
.entry-content ul,
.entry-content ol {
  margin: 1.2em 0 1.2em 1.8em;
  padding: 0;
  line-height: 1.8;
  color: #222;
}
.entry-content li {
  margin: 0.4em 0;
  padding-left: 0.3em;
  text-indent: 0;
  line-height: 1.8;
}

/* 引用块 */
.entry-content blockquote {
  margin: 2em 0;
  padding: 0.8em 1em;
  border-left: 3px solid #aaa;
  background-color: #fafafa;
  color: #444;
  font-size: 0.95rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
}
.entry-content blockquote p {
  margin: 0.8em 0;
  text-indent: 0;
}
.entry-content blockquote p:last-child {
  margin-bottom: 0;
}

/* 行内代码 & 代码块 */
.entry-content code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.9em;
  background-color: #f5f5f5;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: #000;
}
.entry-content pre {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background-color: #f5f5f5;
  color: #000;
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
  margin: 2em 0;
  border: 1px solid #e0e0e0;
  -webkit-overflow-scrolling: touch;
}

/* 图片与图注 */
.entry-content figure {
  margin: 2em auto;
  text-align: center;
  max-width: 100%;
}
.entry-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
}
.entry-content figcaption {
  text-align: center;
  color: #666;
  font-size: 0.9em;
  line-height: 1.5;
  margin-top: 0.6em;
  letter-spacing: 0.02em;
}

/* 分隔线 */
.entry-content hr {
  border: 0;
  border-top: 1px solid #ddd;
  margin: 3rem auto;
  width: 60px;
}

/* 表格 */
.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 0.95rem;
  line-height: 1.6;
}
.entry-content th,
.entry-content td {
  border: 1px solid #ddd;
  padding: 0.6em 0.8em;
  text-align: left;
  vertical-align: top;
}
.entry-content th {
  background-color: #fafafa;
  font-weight: 500;
  color: #000;
}

/* ---------------- 手机优化 ---------------- */
@media (max-width: 600px) {
  .entry-content {
    font-size: 1.1rem;
    line-height: 1.9;
    padding: 1.5rem 1.25rem 3rem; /* 左右加宽,让列表不贴边 */
    max-width: 100%;
  }

  .entry-content p {
    margin: 1em 0;
  }

  .entry-content h2,
  .entry-content h3,
  .entry-content h4 {
    margin: 1.8em 0 0.6em;
  }

  .entry-content h2 {
    border-left-width: 2px;
    padding-left: 0.5em;
    font-size: 1.2rem;
    line-height: 1.4;
  }

  .entry-content h3 {
    border-left-width: 2px;
    padding-left: 0.5em;
    font-size: 1.05rem;
    line-height: 1.45;
  }

  .entry-content blockquote {
    margin: 1.5em 0;
    padding: 0.8em;
    border-left-width: 2px;
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .entry-content ul,
  .entry-content ol {
    margin-left: 2.2em;   /* 增大缩进,避免子弹点靠屏幕 */
    margin-right: 0.8em;  /* 给右侧留白 */
    padding-left: 0.6em;
  }

  .entry-content li {
    padding-left: 0.4em;
    line-height: 1.8;
  }

  .entry-content pre {
    padding: 0.8em;
    font-size: 0.9rem;
    border-radius: 3px;
  }

  .entry-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .entry-content th,
  .entry-content td {
    white-space: nowrap;
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .entry-content hr {
    margin: 1.8rem auto;
    width: 50px;
  }

  .entry-content a {
    padding: 0.1em 0.15em;
  }
}

/* ---------------- 平板优化 ---------------- */
@media (min-width: 600px) and (max-width: 1024px) {
  .entry-content {
    max-width: 640px;
    font-size: 1.075rem;
    line-height: 1.85;
    padding: 2rem 1.5rem 4rem;
  }

  .entry-content h2 {
    border-left-width: 2px;
    padding-left: 0.6em;
    font-size: 1.3rem;
    line-height: 1.4;
  }

  .entry-content h3 {
    border-left-width: 2px;
    border-left-color: #999;
    padding-left: 0.6em;
    font-size: 1.15rem;
    line-height: 1.45;
  }

  .entry-content blockquote {
    margin: 1.8em 0;
    padding: 1em;
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .entry-content pre {
    font-size: 0.9rem;
    padding: 1em;
  }
}
支持

6 评论

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注

  1. 一开始喜欢在 blocksy 的自定义中模块化地调整,后来发现还是得自定义 CSS 才能满足自己的需求 😮‍💨