Skip to content

Commit f9b6e60

Browse files
committed
Updated
1 parent 8e72bdb commit f9b6e60

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

assets/css/extended/custom.css

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ code, pre {
3131
@media (max-width: 768px) {
3232

3333
/* 1. 确保所有公式容器都能滚动 */
34-
.katex-display,
35-
.katex,
3634
.MathJax_Display,
3735
.MathJax {
3836
overflow-x: auto;
@@ -42,29 +40,31 @@ code, pre {
4240
}
4341

4442
/* 2. 块级公式容器加一点内边距,防止滚动条遮挡 */
45-
.katex-display,
4643
.MathJax_Display {
4744
padding-bottom: 4px;
4845
}
4946

5047
/* 3. 允许行内公式在必要时换行 */
51-
/* 强力覆盖 KaTeX 内部的各种 nowrap */
52-
.katex * {
48+
/* 针对移动端强制 MathJax 行内公式换行 */
49+
@media screen and (max-width: 768px) {
50+
/* 目标:强制所有 MathJax 行内公式容器允许换行 */
51+
.post-content mjx-container {
5352
white-space: normal !important;
5453
}
5554

56-
/* 同时让行内公式本身能够自动换行,并保持行内显示 */
57-
.katex {
58-
white-space: normal !important;
59-
word-break: break-word; /* 更优雅的断词方式 */
55+
/* 进阶:仅在必要时对公式内部元素断词,避免破坏结构 */
56+
.post-content mjx-container * {
57+
word-break: break-word;
6058
overflow-wrap: break-word;
6159
}
6260

63-
/* 如果某些 span 还有顽固的 nowrap,直接覆盖 */
64-
.katex [style*="white-space: nowrap"] {
65-
white-space: normal !important;
61+
/* 保留一个优雅的横向滚动方案,作为无法完美换行时的后备 */
62+
.post-content .MathJax_Display,
63+
.post-content mjx-container.MathJax_Display {
64+
overflow-x: auto;
65+
overflow-y: hidden;
6666
}
67-
67+
}
6868
/* 4. 最关键:限制所有父容器不允许溢出 */
6969
.post-content,
7070
.post-content p,

0 commit comments

Comments
 (0)