From 1dc30424aa17969c6e86f71e0b2c672920e6dd20 Mon Sep 17 00:00:00 2001 From: Keldos Date: Wed, 15 Feb 2023 19:28:47 +0800 Subject: [PATCH] feat: resize elements according to --basic-font-size globally --- src/scss/blockquote.scss | 6 +++--- src/scss/footnote.scss | 7 ++++--- src/scss/heading.scss | 10 +++++----- src/scss/settings.scss | 21 ++++++++++++--------- src/scss/text.scss | 9 ++++++++- src/scss/toc.scss | 21 ++++++++++++--------- src/scss/typora.scss | 3 ++- 7 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/scss/blockquote.scss b/src/scss/blockquote.scss index 31c674c..d9d70f7 100644 --- a/src/scss/blockquote.scss +++ b/src/scss/blockquote.scss @@ -5,10 +5,10 @@ blockquote { font-family: var(--quote-font), var(--base-Latin-font), var(--base-Chinese-font), -apple-system, serif; font-size: var(--quote-font-size); /* 文字离左边框的距离 */ - padding-left: 2rem; - padding-right: 2rem; + padding-left: 2em; + padding-right: 2em; /* 左边框离页面边的距离 */ - margin-left: 0rem; + margin-left: 0; } blockquote p:first-child { diff --git a/src/scss/footnote.scss b/src/scss/footnote.scss index ee14c85..995dae7 100644 --- a/src/scss/footnote.scss +++ b/src/scss/footnote.scss @@ -1,9 +1,10 @@ -// 参考文献块 +/* 参考文献(脚注)块 */ +.footnotes { + font-size: 0.95em; +} .footnotes-area { .footnote-line { - // 把参考资料块的文字大小和文字颜色与正文统一 color: var(--text-color); - font-size: var(--base-font-size); } // 默认情况下,Typora 会给参考文献块顶部加一条横线,这里把它隐藏掉 diff --git a/src/scss/heading.scss b/src/scss/heading.scss index 4ef2858..ff45cc2 100644 --- a/src/scss/heading.scss +++ b/src/scss/heading.scss @@ -106,30 +106,30 @@ h6.md-focus.md-heading:before { %h2-with-count { counter-increment: h2; content: counter(h2); - margin-right: 2rem; + margin-right: 1.2em; } %h3-with-count { counter-increment: h3; content: counter(h2) "." counter(h3); - margin-right: 2rem; + margin-right: 1.2em; } %h4-with-count { counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4); - margin-right: 2rem; + margin-right: 1.2em; } %h5-with-count { counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5); - margin-right: 2rem; + margin-right: 1.2em; } %h6-with-count { counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6); - margin-right: 2rem; + margin-right: 1.2em; } diff --git a/src/scss/settings.scss b/src/scss/settings.scss index 26a9de9..feb83ad 100644 --- a/src/scss/settings.scss +++ b/src/scss/settings.scss @@ -30,8 +30,11 @@ /* 引言字体 */ --quote-font: "Latin Modern Roman", "Latin Modern Roman 10", Times, "Times New Roman", "华文仿宋"; - /* 这里字体用了10pt,比正文字体稍大 */ - --quote-font-size: 10pt; + /* em单位为一个正文字符(--base-font-size)大小, + 例如,如果您设置 --base-font-size 为 9.5pt,那么 1.05em = 1.05*9.5pt ≈ 10pt。下面的标题字体等设置也遵循该规则。 + 这样,您就可以仅通过调整基准字体大小,而动态对其他元素大小做出调整。 + 当然,您也可以直接设置以pt或px为单位的数值,将元素的大小固定下来,如 --quote-font-size: 10pt; */ + --quote-font-size: 1.05em; /* 代码字体(代码中的中文会调用 ui-font) */ --code-font: "Latin Modern Mono", "Latin Modern Mono 10", "Courier New"; @@ -74,29 +77,29 @@ /* 标题字体分别设置 */ /* 大标题(h1)字体 */ --title-Chinese-font: "#{$heading-Chinese-font}"; - --title-font-size: 18pt; + --title-font-size: 1.9em; /* h2字体 */ --h2-Chinese-font: "#{$chapter-Chinese-font}"; - --h2-font-size: 14pt; + --h2-font-size: 1.5em; /* h3字体 */ --h3-Chinese-font: "#{$chapter-Chinese-font}"; - --h3-font-size: 12pt; + --h3-font-size: 1.25em; /* h4字体 */ --h4-Chinese-font: "#{$sub-chapter-Chinese-font}"; - --h4-font-size: 10pt; + --h4-font-size: 1.15em; /* h5字体 */ --h5-Chinese-font: "#{$sub-sub-chapter-Chinese-font}"; - --h5-font-size: 10pt; + --h5-font-size: 1.10em; /* h6字体 */ --h6-Chinese-font: "#{$sub-sub-chapter-Chinese-font}"; - --h6-font-size: 9.5pt; + --h6-font-size: 1.05em; /* 粗体样式设置 */ /* 加粗风格时使用的字重;400等同于 normal,700等同于 bold,900等同于 heavy */ --strong-weight: 900; /* 基础行距 */ - --base-line-height: 16pt; + --base-line-height: 1.618em; /* == 页面设置 == */ /* 打印页边距 */ diff --git a/src/scss/text.scss b/src/scss/text.scss index f24969d..f59ff3c 100644 --- a/src/scss/text.scss +++ b/src/scss/text.scss @@ -1,7 +1,7 @@ body { padding: 0 !important; margin: 0 !important; - line-height: var(--base-line-height); + // line-height: var(--base-line-height); /* counter-reset: tableHead 0 imgHead 0; */ @if $theme == "dark" { color: #dddddd; @@ -34,8 +34,15 @@ body { display: inline-block; */ /* 这里可以试分栏的,但确实不适合实现 */ + .md-math-block, + .md-rawblock, + p { + margin-top: 1em; + margin-bottom: 1em; + } p { text-align: left; + line-height: var(--base-line-height); } // 超链接 diff --git a/src/scss/toc.scss b/src/scss/toc.scss index 55d0474..95756f7 100644 --- a/src/scss/toc.scss +++ b/src/scss/toc.scss @@ -1,4 +1,7 @@ /* 目录 */ +.md-toc { + font-size: var(--toc-font-size); +} .md-toc-content { margin-left: 2em; /* 修复缺失上级标题时无法递增 */ @@ -56,33 +59,33 @@ .md-toc-h2:before { counter-increment: toc-h2; content: counter(toc-h2); - margin-right: 1rem; + margin-right: 1em; font-weight: var(--strong-weight); } .md-toc-h3:before { counter-increment: toc-h3; content: counter(toc-h2) "." counter(toc-h3); - margin-left: 1.5rem; - margin-right: 0.5rem; + margin-left: 1.5em; + margin-right: 0.5em; } .md-toc-h4:before { counter-increment: toc-h4; content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4); - margin-left: 3.5rem; - margin-right: 0.5rem; + margin-left: 3.5em; + margin-right: 0.5em; } .md-toc-h5:before { counter-increment: toc-h5; content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "." counter(toc-h5); - margin-left: 5.5rem; - margin-right: 0.5rem; + margin-left: 5.5em; + margin-right: 0.5em; } .md-toc-h6:before { counter-increment: toc-h6; content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "." counter(toc-h5) "." counter(toc-h6); - margin-left: 7.5rem; - margin-right: 0.5rem; + margin-left: 7.5em; + margin-right: 0.5em; } } \ No newline at end of file diff --git a/src/scss/typora.scss b/src/scss/typora.scss index f03884c..90cda50 100644 --- a/src/scss/typora.scss +++ b/src/scss/typora.scss @@ -26,7 +26,7 @@ } font-family: var(--sourceMode-font), var(--code-font), var(--ui-font), monospace; - line-height: 2rem; + line-height: 2em; } /* 侧边大纲标题 */ @@ -87,6 +87,7 @@ pre.md-meta-block { } padding: 1.4em; font-family: var(--code-font), var(--ui-font), monospace; + font-size: 0.8em; } // override the default style for focused headings