|
15 | 15 | box-sizing: border-box; /* 内边距不影响宽度计算,避免溢出 */ |
16 | 16 | } |
17 | 17 |
|
18 | | -/* 2. 左侧侧边栏 - 精准类名(ty-blog-sidebar) */ |
| 18 | +/* 2. 左侧侧边栏 - 精准类名(ty-blog-sidebar) |
| 19 | + 修复:强化手机端+所有子元素居中,覆盖主题默认样式 */ |
19 | 20 | .ty-blog-sidebar { |
20 | 21 | width: 280px; /* 侧边栏固定宽度,可自定义调整 */ |
21 | 22 | flex-shrink: 0; /* 防止侧边栏被内容区压缩,保证宽度稳定 */ |
|
28 | 29 | /* 主题兼容性:继承父级字体样式,不强行覆盖 */ |
29 | 30 | font-family: inherit; |
30 | 31 | font-size: inherit; |
| 32 | + /* 修复:强制子元素继承居中对齐,避免主题样式覆盖 */ |
| 33 | + display: flex; |
| 34 | + flex-direction: column; |
| 35 | + align-items: center; |
| 36 | + justify-content: flex-start; |
31 | 37 | } |
32 | 38 |
|
33 | 39 | /* 2.1 侧边栏 Logo 样式 - 精准控制,避免覆盖主题图片 */ |
|
38 | 44 | display: block; /* 确保 margin: 0 auto 生效 */ |
39 | 45 | } |
40 | 46 |
|
41 | | -/* 2.2 侧边栏文字/链接样式 - 兼容主题颜色,避免冲突 */ |
| 47 | +/* 2.2 侧边栏文字/链接样式 - 兼容主题颜色,避免冲突 |
| 48 | + 修复:强化居中,确保手机端也不会错位 */ |
42 | 49 | .ty-blog-sidebar__title, |
43 | 50 | .ty-blog-sidebar__desc, |
44 | 51 | .ty-blog-sidebar__link { |
45 | 52 | margin-bottom: 12px; |
46 | 53 | color: var(--color-text, #333); /* 文字颜色使用 CSS 变量,兼容深色模式 */ |
47 | 54 | text-decoration: none; /* 去除链接默认下划线(可选,保持主题风格) */ |
| 55 | + /* 修复:强制居中,覆盖主题默认的左对齐 */ |
| 56 | + text-align: center; |
| 57 | + display: inline-block; |
48 | 58 | } |
49 | 59 |
|
50 | 60 | .ty-blog-sidebar__link:hover { |
51 | 61 | color: var(--color-link-hover, #0366d6); /* hover 颜色继承主题,提升兼容性 */ |
52 | 62 | text-decoration: underline; |
53 | 63 | } |
54 | 64 |
|
55 | | -/* 2.3 侧边栏下载按钮列表 - 精准类名,避免覆盖全局 ul */ |
| 65 | +/* 2.3 侧边栏下载按钮列表 - 精准类名,避免覆盖全局 ul |
| 66 | + 修复:强化列表项居中,手机端无错位 */ |
56 | 67 | .ty-blog-sidebar__downloads { |
57 | 68 | list-style: none; /* 去除默认列表圆点 */ |
58 | 69 | padding: 0; /* 去除默认内边距 */ |
59 | 70 | margin: 20px 0 0; /* 顶部间距,和上方内容分隔 */ |
| 71 | + /* 修复:列表整体居中 */ |
| 72 | + text-align: center; |
| 73 | + width: 100%; |
60 | 74 | } |
61 | 75 |
|
62 | 76 | .ty-blog-sidebar__downloads li { |
63 | 77 | margin-bottom: 8px; /* 按钮之间的间距 */ |
| 78 | + /* 修复:列表项居中 */ |
| 79 | + text-align: center; |
64 | 80 | } |
65 | 81 |
|
66 | | -/* 3. 右侧文章内容区 - 精准类名(ty-blog-content) */ |
| 82 | +/* 3. 右侧文章内容区 - 精准类名(ty-blog-content) |
| 83 | + 补充:强化所有子元素颜色,解决主页文字和背景融为一体的问题 */ |
67 | 84 | .ty-blog-content { |
68 | 85 | flex: 1; /* 占据剩余所有宽度,自适应布局 */ |
69 | 86 | max-width: 850px; /* 内容区最大宽度,保证阅读体验(避免大屏文字过宽) */ |
70 | 87 | margin: 0 auto; /* 内容区自身水平居中,满足你的核心需求 */ |
71 | 88 | padding: 10px 0; /* 上下内边距,避免内容贴边 */ |
72 | 89 | box-sizing: border-box; |
| 90 | + /* 补充:强制子元素继承文字颜色,防止主题默认浅色文字 */ |
| 91 | + color: var(--color-text, #333); |
73 | 92 | } |
74 | 93 |
|
75 | | -/* 3.1 文章内容排版优化 - 兼容主题,提升阅读体验 */ |
| 94 | +/* 3.1 文章内容排版优化 - 兼容主题,提升阅读体验 |
| 95 | + 补充:增加更多选择器(div、span、ul、ol),覆盖主页所有文字元素 */ |
76 | 96 | .ty-blog-content h1, |
77 | 97 | .ty-blog-content h2, |
78 | | -.ty-blog-content h3 { |
| 98 | +.ty-blog-content h3, |
| 99 | +.ty-blog-content h4, |
| 100 | +.ty-blog-content h5, |
| 101 | +.ty-blog-content h6 { |
79 | 102 | margin-top: 25px; |
80 | 103 | margin-bottom: 15px; |
81 | | - color: var(--color-text-heading, #222); /* 标题颜色使用 CSS 变量 */ |
| 104 | + color: var(--color-text-heading, #222); /* 标题颜色使用 CSS 变量,解决融为一体问题 */ |
82 | 105 | } |
83 | 106 |
|
84 | | -.ty-blog-content p { |
| 107 | +.ty-blog-content p, |
| 108 | +.ty-blog-content div, |
| 109 | +.ty-blog-content span, |
| 110 | +.ty-blog-content ul, |
| 111 | +.ty-blog-content ol { |
85 | 112 | line-height: 1.7; |
86 | 113 | margin-bottom: 15px; |
87 | | - color: var(--color-text, #333); |
| 114 | + color: var(--color-text, #333); /* 正文文字颜色,解决融为一体问题 */ |
| 115 | +} |
| 116 | + |
| 117 | +/* 补充:主页链接样式,避免链接也和背景融为一体 */ |
| 118 | +.ty-blog-content a { |
| 119 | + color: var(--color-link-hover, #0366d6); |
| 120 | + text-decoration: none; |
| 121 | +} |
| 122 | + |
| 123 | +.ty-blog-content a:hover { |
| 124 | + text-decoration: underline; |
88 | 125 | } |
89 | 126 |
|
90 | 127 | /* 4. 页脚优化 - 独立类名(ty-blog-footer),位置合理 */ |
|
106 | 143 | :root { |
107 | 144 | /* 背景色 */ |
108 | 145 | --color-bg-sidebar: rgba(248, 248, 248, 0.8); |
| 146 | + --color-bg-content: #ffffff; /* 补充:内容区背景色,避免浅色模式下文字模糊 */ |
109 | 147 | /* 边框色 */ |
110 | 148 | --color-border: #eaeaea; |
111 | 149 | /* 文字色 */ |
|
121 | 159 | @media (prefers-color-scheme: dark) { |
122 | 160 | :root { |
123 | 161 | --color-bg-sidebar: rgba(30, 30, 30, 0.8); |
| 162 | + --color-bg-content: #1a1a1a; /* 补充:深色模式内容区背景色 */ |
124 | 163 | --color-border: #333; |
125 | 164 | --color-text: #eaeaea; |
126 | 165 | --color-text-heading: #fff; |
127 | 166 | --color-text-secondary: #aaa; |
128 | 167 | --color-link-hover: #4eaaff; |
129 | 168 | } |
| 169 | + /* 补充:深色模式下 body 背景色,避免整体违和 */ |
| 170 | + body { |
| 171 | + background-color: #121212; |
| 172 | + } |
130 | 173 | } |
131 | 174 |
|
132 | 175 | /* 方案2:兼容主题自定义 .dark 类(部分 Jekyll 主题自带) */ |
133 | 176 | .dark .ty-blog-container, |
134 | 177 | .dark .ty-blog-sidebar, |
135 | 178 | .dark .ty-blog-content { |
136 | 179 | --color-bg-sidebar: rgba(30, 30, 30, 0.8); |
| 180 | + --color-bg-content: #1a1a1a; |
137 | 181 | --color-border: #333; |
138 | 182 | --color-text: #eaeaea; |
139 | 183 | --color-text-heading: #fff; |
140 | 184 | --color-text-secondary: #aaa; |
141 | 185 | --color-link-hover: #4eaaff; |
142 | 186 | } |
143 | 187 |
|
144 | | -/* 6. 响应式适配 - 手机端自动变回上下布局,兼容移动端 */ |
| 188 | +/* 6. 响应式适配 - 手机端自动变回上下布局,兼容移动端 |
| 189 | + 修复:强化手机端侧边栏居中,确保无错位 */ |
145 | 190 | @media (max-width: 768px) { |
146 | 191 | .ty-blog-container { |
147 | 192 | flex-direction: column; /* 手机端:上下排列,避免拥挤 */ |
|
152 | 197 | .ty-blog-sidebar { |
153 | 198 | width: 100%; /* 侧边栏占满屏幕宽度 */ |
154 | 199 | margin-bottom: 0; /* 配合 gap,无需额外间距 */ |
| 200 | + /* 修复:手机端侧边栏强制居中,覆盖任何主题样式 */ |
| 201 | + text-align: center; |
| 202 | + align-items: center; |
| 203 | + justify-content: center; |
155 | 204 | } |
156 | 205 |
|
157 | 206 | .ty-blog-content { |
158 | 207 | max-width: 100%; /* 移动端内容区占满宽度 */ |
| 208 | + /* 补充:手机端内容区文字不贴边 */ |
| 209 | + padding: 10px 15px; |
159 | 210 | } |
160 | 211 |
|
161 | 212 | .ty-blog-footer { |
|
0 commit comments