-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmobile-optimizations.css
More file actions
497 lines (416 loc) · 9.31 KB
/
mobile-optimizations.css
File metadata and controls
497 lines (416 loc) · 9.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
/**
* 移动端优化样式
* 优化移动设备上的用户体验
*/
/* 触摸优化 */
@media (max-width: 768px) {
/* 增大触摸目标 */
button, .btn, a, input[type="submit"], input[type="button"] {
min-height: 44px;
min-width: 44px;
padding: 12px 16px;
}
/* 导航链接优化 */
.nav-link, .navbar-nav a {
min-height: 48px;
display: flex;
align-items: center;
padding: 12px 16px;
}
/* 表单元素优化 */
input, textarea, select {
min-height: 44px;
font-size: 16px; /* 防止 iOS 缩放 */
padding: 12px;
}
/* 搜索框优化 */
.search-box {
font-size: 16px;
padding: 16px;
min-height: 52px;
}
/* 搜索结果优化 */
.search-item {
min-height: 60px;
padding: 16px;
}
/* 卡片优化 */
.feature-card, .post-card {
padding: 24px 20px;
min-height: auto;
}
/* 按钮优化 */
.hero-buttons {
flex-direction: column;
width: 100%;
}
.btn {
width: 100%;
justify-content: center;
min-height: 48px;
}
/* 搜索覆盖层优化 */
.search-container {
width: 95%;
margin-top: 5vh;
}
.search-results {
max-height: 50vh;
}
/* 移动端菜单优化 */
.navbar-nav {
padding-top: 20px;
}
.nav-link {
width: 100%;
text-align: left;
padding: 16px;
border-bottom: 1px solid var(--border-color);
}
/* 统计数据优化 */
.stats-container {
grid-template-columns: repeat(2, 1fr);
gap: 20px;
}
.stat-item {
padding: 16px;
}
.stat-number {
font-size: 2rem;
}
/* 功能卡片优化 */
.features-grid {
grid-template-columns: 1fr;
gap: 20px;
}
/* 分类卡片优化 */
.category-grid {
grid-template-columns: 1fr;
gap: 16px;
}
.category-links {
grid-template-columns: 1fr;
}
/* 文章列表优化 */
.posts-header {
flex-direction: column;
align-items: flex-start;
gap: 12px;
}
/* 页脚优化 */
.footer {
padding: 32px 16px;
}
.social-links {
flex-wrap: wrap;
gap: 12px;
}
/* 主题切换按钮优化 */
.theme-toggle {
width: 50px;
height: 50px;
bottom: 20px;
right: 20px;
}
.theme-toggle i {
font-size: 20px;
}
}
/* 超小屏幕优化 */
@media (max-width: 480px) {
/* 英雄区域优化 */
.hero {
padding: 60px 16px;
}
.hero h1 {
font-size: 2rem;
line-height: 1.2;
}
.hero-subtitle {
font-size: 1.1rem;
}
.hero-desc {
font-size: 1rem;
padding: 0 10px;
}
/* 章节标题优化 */
.section-title {
font-size: 1.75rem;
}
.section-subtitle {
font-size: 1rem;
}
/* 统计数据进一步优化 */
.stats-container {
grid-template-columns: 1fr;
gap: 16px;
}
.stat-number {
font-size: 2.5rem;
}
/* 功能图标优化 */
.feature-icon {
width: 60px;
height: 60px;
font-size: 1.5rem;
}
/* 文章卡片优化 */
.post-card {
padding: 20px 16px;
}
.post-title {
font-size: 1.1rem;
}
.post-excerpt {
font-size: 0.9rem;
}
/* 搜索优化 */
.search-header {
padding: 16px;
}
.search-input {
font-size: 16px;
padding: 12px;
}
.search-close {
width: 36px;
height: 36px;
font-size: 20px;
}
}
/* 触摸反馈优化 */
@media (hover: none) and (pointer: coarse) {
/* 移除悬停效果,使用触摸反馈 */
.nav-link:hover,
.feature-card:hover,
.post-card:hover,
.btn:hover {
transform: none;
}
/* 添加触摸反馈 */
.nav-link:active,
.feature-card:active,
.post-card:active,
.btn:active {
opacity: 0.7;
transform: scale(0.98);
}
/* 按钮触摸反馈 */
button:active,
.btn:active {
background-color: var(--primary-hover);
}
}
/* 横屏模式优化 */
@media (max-height: 600px) and (orientation: landscape) {
/* 英雄区域压缩 */
.hero {
padding: 40px 16px;
}
.hero h1 {
font-size: 2rem;
margin-bottom: 12px;
}
.hero-buttons {
margin-bottom: 20px;
}
/* 搜索覆盖层优化 */
.search-container {
margin-top: 2vh;
}
.search-results {
max-height: 40vh;
}
}
/* iOS Safari 特定优化 */
@supports (-webkit-touch-callout: none) {
/* 修复 iOS Safari 的点击高亮 */
* {
-webkit-tap-highlight-color: transparent;
}
/* 修复 iOS Safari 的滚动弹性 */
body {
-webkit-overflow-scrolling: touch;
}
/* 修复 iOS Safari 的输入框缩放 */
input, textarea, select {
font-size: 16px !important;
}
}
/* 高 DPI 屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
/* 确保文本清晰 */
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* 优化边框显示 */
.feature-card, .post-card {
border-width: 0.5px;
}
}
/* 减少动画效果(省电模式) */
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
.hero::before {
animation: none;
}
}
/* 暗色模式下的移动端优化 */
.dark-mode @media (max-width: 768px) {
/* 搜索框优化 */
.search-input {
background: #374151;
border-color: #4b5563;
color: #f9fafb;
}
/* 搜索结果优化 */
.search-item {
border-bottom-color: #374151;
}
/* 搜索分类优化 */
.search-category {
background: #374151;
color: #9ca3af;
}
}
/* 性能优化:减少重排 */
@media (max-width: 768px) {
/* 使用 transform 代替位置属性 */
.navbar-nav.active {
transform: translateX(0);
}
.navbar-nav {
transform: translateX(-100%);
transition: transform 0.3s ease;
}
/* 使用 opacity 代替 display */
.search-overlay.active {
opacity: 1;
pointer-events: auto;
}
.search-overlay {
opacity: 0;
pointer-events: none;
transition: opacity 0.2s ease;
}
}
/* 移动端特定功能 */
@media (max-width: 768px) {
/* 添加返回顶部按钮 */
#back-to-top {
bottom: 80px;
right: 20px;
}
#back-to-top a {
width: 50px;
height: 50px;
}
/* 优化图片加载 */
img {
max-width: 100%;
height: auto;
display: block;
}
/* 优化表格显示 */
table {
display: block;
overflow-x: auto;
white-space: nowrap;
}
/* 优化代码块显示 */
pre, code {
font-size: 14px;
overflow-x: auto;
max-width: 100%;
}
/* 优化长文本显示 */
.post-excerpt, .feature-desc {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
}
/* 移动端导航优化 */
@media (max-width: 768px) {
/* 汉堡菜单优化 */
.mobile-menu-toggle {
width: 36px;
height: 30px;
}
.mobile-menu-toggle span {
height: 3px;
border-radius: 2px;
}
/* 导航栏高度优化 */
.navbar {
height: 56px;
}
.navbar-container {
height: 56px;
padding: 0 16px;
}
.navbar-brand img {
width: 28px;
height: 28px;
}
.navbar-brand {
font-size: 1.1rem;
}
}
/* 移动端搜索优化 */
@media (max-width: 768px) {
/* 搜索快捷键提示 */
.search-shortcut {
display: none;
}
/* 搜索结果滚动优化 */
.search-results {
-webkit-overflow-scrolling: touch;
}
/* 搜索输入优化 */
.search-input::placeholder {
font-size: 16px;
}
}
/* 移动端性能优化 */
@media (max-width: 768px) {
/* 减少阴影效果 */
.feature-card, .post-card {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
/* 简化渐变效果 */
.hero {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
/* 优化字体加载 */
body {
font-display: swap;
}
}
/* 移动端无障碍优化 */
@media (max-width: 768px) {
/* 确保足够的点击区域 */
.social-link {
width: 48px;
height: 48px;
}
/* 优化表单标签 */
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
}
/* 优化错误提示 */
.error-message {
padding: 12px;
margin: 12px 0;
border-left: 4px solid #ef4444;
background: #fef2f2;
}
}