定制样式

由于 MarkDown 语法本身是 HTML 语言的一个子集,按照 Web 标准的精神(内容、表现和行为三者分离),MarkDown 语法中,没有和内容表现形式相关的语法规则。因此,要实现自定义样式,必须从 CSS 或者插件入手。

GitBook 官方手册 介绍,我们可以通过在项目文件夹中创建特定样式表的方式达到自定义样式的目的:

You can specify CSS files to be included in your book's website or PDF builds by creating files:

styles/website.css: will apply only to the website

styles/pdf.css: will apply only to the PDF

styles/ebook.css: will apply only to ebook formats (PDF, Mobi, ePub)

例如,编辑 styles/website.css 文件:

/* 左侧导航栏 */
.book .book-summary {
    font-family: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft Yahei", "Lantinghei SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "WenQuanYi Zen Hei", "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang TC", "Lantinghei TC", "Noto Sans CJK TC", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 1em;
}

/* 正文 */
.book .book-body {
    font-family: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft Yahei", "Lantinghei SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", "WenQuanYi Zen Hei", "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang TC", "Lantinghei TC", "Noto Sans CJK TC", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 1.1em;
}

/* 代码块 */
.markdown-section pre>code {
    font-family: "Monaco", "InputMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: .9em;
}

/* 行内代码块 */
.markdown-section code {
    font-family: "Monaco", "InputMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: .85em;
}

results matching ""

    No results matching ""