_reader-content.css 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* resources/css/modules/_reader-content.css
  2. 阅读器正文排版。所有规则限定在 article.reader-body 作用域内。
  3. 包含:基础排版、Tufte sidenote 集成、响应式断点对齐。
  4. */
  5. /* ══════════════════════════════════════════
  6. 一、作用域根:正文必须用 <article class="reader-body"> 包裹
  7. ══════════════════════════════════════════ */
  8. article.reader-body {
  9. font-family: 'Noto Serif', Georgia, serif;
  10. font-size: 1.05rem;
  11. line-height: 1.75;
  12. color: inherit;
  13. counter-reset: sidenote-counter;
  14. }
  15. article.reader-body div.sentence {
  16. display: inline;
  17. }
  18. article.reader-body div.translation .para-block {
  19. margin-bottom: 0.75em;
  20. }
  21. /* ── 段落 ── */
  22. article.reader-body p {
  23. margin-bottom: 1.25rem;
  24. padding-right: 0;
  25. vertical-align: baseline;
  26. }
  27. /* ── 标题 ── */
  28. article.reader-body h1,
  29. article.reader-body h2,
  30. article.reader-body h3,
  31. article.reader-body h4 {
  32. font-weight: 600;
  33. line-height: 1.3;
  34. margin-top: 2rem;
  35. margin-bottom: 0.75rem;
  36. }
  37. /* ── 列表:只在正文内收缩,不影响外部 ── */
  38. article.reader-body ul,
  39. article.reader-body ol {
  40. padding-left: 1.5rem;
  41. margin-bottom: 1.25rem;
  42. }
  43. article.reader-body li {
  44. line-height: 1.7;
  45. margin-bottom: 0.25rem;
  46. }
  47. /* ── 引用块 ── */
  48. article.reader-body blockquote {
  49. margin: 1.5rem 0 1.5rem 0;
  50. padding: 0.75rem 1.25rem;
  51. border-left: 3px solid var(--tblr-border-color);
  52. color: var(--tblr-secondary);
  53. font-style: italic;
  54. }
  55. /* ── 分割线 ── */
  56. article.reader-body hr {
  57. display: block;
  58. height: 1px;
  59. border: 0;
  60. border-top: 1px solid #ccc;
  61. margin: 2em 0;
  62. }
  63. /* ── 代码块 ── */
  64. article.reader-body pre > code {
  65. display: block;
  66. overflow-x: auto;
  67. font-size: 0.9rem;
  68. line-height: 1.5;
  69. padding: 1rem;
  70. background: var(--tblr-bg-surface-secondary);
  71. border-radius: var(--tblr-border-radius);
  72. }
  73. /* ══════════════════════════════════════════
  74. 二、Tufte Sidenote / Marginnote
  75. 断点与 reader 对齐:>= 992px 浮动显示,< 992px 点击展开
  76. ══════════════════════════════════════════ */
  77. /* 触发标签(手机/平板用) */
  78. article.reader-body input.margin-toggle {
  79. display: none;
  80. }
  81. article.reader-body label.sidenote-number {
  82. display: inline-block;
  83. max-height: 1.75rem;
  84. }
  85. /* ≥ 992px:浮动 sidenote,右侧边栏同时存在,布局一致 */
  86. @media (min-width: 992px) {
  87. article.reader-body label.margin-toggle:not(.sidenote-number) {
  88. display: none;
  89. }
  90. article.reader-body .sidenote,
  91. article.reader-body .marginnote {
  92. float: right;
  93. clear: right;
  94. margin-right: -35%;
  95. width: 28%;
  96. margin-top: 0.3rem;
  97. margin-bottom: 0;
  98. font-size: 0.875rem;
  99. line-height: 1.4;
  100. vertical-align: baseline;
  101. position: relative;
  102. border: 1px solid wheat;
  103. padding: 6px;
  104. border-radius: 8px;
  105. background-color: #f5deb330;
  106. }
  107. .dark-mode article.reader-body .sidenote,
  108. .dark-mode article.reader-body .marginnote {
  109. border-color: #6b5a3e;
  110. background-color: rgba(139, 109, 56, 0.15);
  111. }
  112. }
  113. /* < 992px:与手机一致,点击展开 */
  114. @media (max-width: 991px) {
  115. article.reader-body label.margin-toggle:not(.sidenote-number) {
  116. display: inline;
  117. cursor: pointer;
  118. color: var(--tblr-primary);
  119. }
  120. article.reader-body .sidenote,
  121. article.reader-body .marginnote {
  122. display: none;
  123. }
  124. article.reader-body .margin-toggle:checked + .sidenote,
  125. article.reader-body .margin-toggle:checked + .marginnote {
  126. display: block;
  127. float: left;
  128. left: 0;
  129. clear: both;
  130. width: 95%;
  131. margin: 0.75rem 2.5%;
  132. position: relative;
  133. border: 1px solid wheat;
  134. padding: 6px;
  135. border-radius: 8px;
  136. background-color: #f5deb330;
  137. }
  138. }
  139. /* sidenote 编号上标 */
  140. article.reader-body .sidenote-number {
  141. counter-increment: sidenote-counter;
  142. }
  143. article.reader-body .sidenote-number::after,
  144. article.reader-body .sidenote::before {
  145. position: relative;
  146. vertical-align: baseline;
  147. }
  148. article.reader-body .sidenote-number::after {
  149. content: '[' counter(sidenote-counter) ']';
  150. font-size: 0.75rem;
  151. top: -0.5rem;
  152. left: 0.1rem;
  153. color: var(--tblr-primary);
  154. }
  155. article.reader-body .sidenote::before {
  156. content: counter(sidenote-counter) ' ';
  157. font-size: 0.75rem;
  158. top: -0.5rem;
  159. }
  160. /* ══════════════════════════════════════════
  161. 三、Commentary 注释(点击展开,始终在句子下方)
  162. DOM 结构(由 JS 注入):
  163. div.sentence
  164. input.commentary-toggle#commentary-N
  165. div.commentary-note[data-uuid]
  166. ══════════════════════════════════════════ */
  167. /* checkbox 隐藏 */
  168. article.reader-body input.commentary-toggle {
  169. display: none;
  170. }
  171. /* icon label:行内,插在句子文字末尾 */
  172. article.reader-body label.commentary-icon {
  173. display: inline;
  174. cursor: pointer;
  175. margin-left: 4px;
  176. color: var(--tblr-primary);
  177. vertical-align: middle;
  178. font-size: 0.85rem;
  179. user-select: none;
  180. transition: opacity 0.15s;
  181. }
  182. article.reader-body label.commentary-icon:hover {
  183. opacity: 0.7;
  184. }
  185. /* 注释块默认隐藏 */
  186. article.reader-body .commentary-note {
  187. display: none;
  188. }
  189. /* 展开:checkbox checked → 相邻的 .commentary-note 显示 */
  190. article.reader-body .commentary-toggle:checked + .commentary-note {
  191. display: block;
  192. clear: both;
  193. width: 95%;
  194. margin: 0.5rem 2.5% 0.75rem;
  195. padding: 8px 12px;
  196. border-left: 3px solid var(--tblr-primary);
  197. border-radius: 0 6px 6px 0;
  198. background-color: #f5deb330;
  199. font-size: 0.875rem;
  200. line-height: 1.6;
  201. }
  202. .dark-mode article.reader-body .commentary-toggle:checked + .commentary-note {
  203. background-color: rgba(139, 109, 56, 0.15);
  204. }
  205. /* ══════════════════════════════════════════
  206. 四、正文内 origin(原文显示)
  207. ══════════════════════════════════════════ */
  208. article.reader-body .origin {
  209. color: darkred;
  210. }
  211. .dark-mode article.reader-body .origin {
  212. color: #ff8a8a;
  213. }
  214. /* ══════════════════════════════════════════
  215. 五、Epigraph(题词)
  216. ══════════════════════════════════════════ */
  217. article.reader-body div.epigraph {
  218. margin: 3em 0;
  219. }
  220. article.reader-body div.epigraph > blockquote,
  221. article.reader-body div.epigraph > blockquote > p {
  222. font-style: italic;
  223. }
  224. article.reader-body div.epigraph > blockquote > footer {
  225. font-style: normal;
  226. text-align: right;
  227. font-size: 0.9rem;
  228. }