-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
697 lines (667 loc) · 25.3 KB
/
Copy pathindex.html
File metadata and controls
697 lines (667 loc) · 25.3 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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>wjs-web-application - HTML/CSS 布局与业务页面实战笔记</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
background: #f5f7fa;
color: #303133;
line-height: 1.6;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
padding: 60px 20px;
text-align: center;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
font-weight: 700;
}
.header p {
font-size: 1.1rem;
opacity: 0.9;
margin-bottom: 20px;
}
.stats {
display: flex;
justify-content: center;
gap: 40px;
margin-top: 30px;
flex-wrap: wrap;
}
.stat-item {
text-align: center;
}
.stat-number {
font-size: 2rem;
font-weight: 700;
}
.stat-label {
font-size: 0.9rem;
opacity: 0.85;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 40px 20px;
}
.search-box {
margin-bottom: 30px;
position: relative;
}
.search-box input {
width: 100%;
padding: 15px 20px 15px 50px;
font-size: 1rem;
border: 2px solid #e4e7ed;
border-radius: 12px;
outline: none;
transition: all 0.3s;
background: #fff;
}
.search-box input:focus {
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.search-box::before {
content: '🔍';
position: absolute;
left: 18px;
top: 50%;
transform: translateY(-50%);
font-size: 1.2rem;
}
.section-title {
font-size: 1.5rem;
font-weight: 600;
margin: 40px 0 20px;
padding-bottom: 10px;
border-bottom: 2px solid #667eea;
display: inline-block;
}
.module-tabs {
display: flex;
gap: 10px;
margin-bottom: 30px;
flex-wrap: wrap;
}
.module-tab {
padding: 10px 24px;
border-radius: 8px;
cursor: pointer;
background: #fff;
color: #606266;
font-size: 0.95rem;
transition: all 0.2s;
border: 2px solid #e4e7ed;
font-weight: 500;
}
.module-tab:hover {
border-color: #667eea;
color: #667eea;
}
.module-tab.active {
background: #667eea;
color: #fff;
border-color: #667eea;
}
.module-content {
display: none;
}
.module-content.active {
display: block;
}
.category-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
margin-bottom: 40px;
}
.category-card {
background: #fff;
border-radius: 12px;
padding: 24px;
cursor: pointer;
transition: all 0.3s;
border: 1px solid #ebeef5;
text-decoration: none;
color: inherit;
display: block;
position: relative;
overflow: hidden;
}
.category-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
transition: height 0.3s;
}
.category-card:hover::before {
height: 100%;
}
.category-card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
border-color: #667eea;
}
.category-icon {
font-size: 2.5rem;
margin-bottom: 12px;
}
.category-title {
font-size: 1.15rem;
font-weight: 600;
margin-bottom: 8px;
color: #303133;
display: flex;
align-items: center;
justify-content: space-between;
}
.category-title .arrow {
font-size: 1rem;
color: #c0c4cc;
transition: transform 0.3s, color 0.3s;
}
.category-card:hover .arrow {
transform: translateX(4px);
color: #667eea;
}
.category-desc {
font-size: 0.9rem;
color: #909399;
margin-bottom: 12px;
line-height: 1.5;
min-height: 42px;
}
.category-meta {
display: flex;
justify-content: space-between;
align-items: center;
}
.category-count {
display: inline-block;
background: #ecf5ff;
color: #409eff;
padding: 4px 12px;
border-radius: 20px;
font-size: 0.85rem;
font-weight: 500;
}
.category-year {
font-size: 0.8rem;
color: #c0c4cc;
font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}
.timeline {
background: #fff;
border-radius: 12px;
padding: 30px;
border: 1px solid #ebeef5;
margin-bottom: 40px;
}
.timeline-item {
display: flex;
padding: 15px 0;
border-bottom: 1px dashed #ebeef5;
align-items: flex-start;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-year {
width: 80px;
font-weight: 700;
color: #667eea;
flex-shrink: 0;
font-size: 1.1rem;
}
.timeline-content {
flex: 1;
color: #606266;
}
.timeline-content strong {
color: #303133;
}
.code-block {
background: #282c34;
color: #abb2bf;
border-radius: 8px;
padding: 20px;
font-family: 'SF Mono', Monaco, 'Courier New', monospace;
font-size: 0.9rem;
overflow-x: auto;
margin: 20px 0;
line-height: 1.8;
white-space: pre;
word-wrap: normal;
}
.code-block code {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
.code-block .kw { color: #c678dd; }
.code-block .str { color: #98c379; }
.code-block .cm { color: #5c6370; }
.code-block .fn { color: #61afef; }
.code-block .tag { color: #e06c75; }
.code-block .attr { color: #d19a66; }
.usage-tabs {
display: flex;
gap: 10px;
margin-bottom: 15px;
flex-wrap: wrap;
}
.usage-tab {
padding: 8px 20px;
border-radius: 8px;
cursor: pointer;
background: #f5f7fa;
color: #606266;
font-size: 0.9rem;
transition: all 0.2s;
border: 1px solid transparent;
}
.usage-tab:hover {
background: #ecf5ff;
color: #409eff;
}
.usage-tab.active {
background: #667eea;
color: #fff;
}
.usage-content {
display: none;
}
.usage-content.active {
display: block;
}
.usage-section {
background: #fff;
border-radius: 12px;
padding: 30px;
border: 1px solid #ebeef5;
margin-bottom: 40px;
}
.feature-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-top: 20px;
}
.feature-item {
padding: 15px;
background: #f8f9fc;
border-radius: 8px;
font-size: 0.9rem;
color: #606266;
display: flex;
align-items: center;
gap: 8px;
}
.feature-item::before {
content: '✓';
color: #67c23a;
font-weight: 700;
}
.footer {
text-align: center;
padding: 40px 20px;
color: #909399;
font-size: 0.9rem;
}
.footer a {
color: #667eea;
text-decoration: none;
}
.hidden { display: none !important; }
.no-result {
text-align: center;
padding: 60px 20px;
color: #909399;
}
.no-result-icon {
font-size: 3rem;
margin-bottom: 15px;
}
.badge {
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: 0.75rem;
font-weight: 500;
margin-left: 8px;
}
.badge-new {
background: #f0f9eb;
color: #67c23a;
}
.badge-hot {
background: #fef0f0;
color: #f56c6c;
}
</style>
</head>
<body>
<div class="header">
<h1>🎨 wjs-web-application</h1>
<p>11年前端开发积累 · HTML/CSS 布局与业务页面实战笔记</p>
<div class="stats">
<div class="stat-item">
<div class="stat-number">3</div>
<div class="stat-label">核心模块</div>
</div>
<div class="stat-item">
<div class="stat-number">20+54+10</div>
<div class="stat-label">布局+页面+CSS工具</div>
</div>
<div class="stat-item">
<div class="stat-number">2015-2026</div>
<div class="stat-label">持续积累</div>
</div>
</div>
</div>
<div class="container">
<div class="search-box">
<input type="text" id="searchInput" placeholder="搜索布局、页面、CSS工具类..." oninput="handleSearch()">
</div>
<h2 class="section-title">📦 三大模块</h2>
<div class="module-tabs">
<div class="module-tab active" onclick="switchModule(0)">🏗️ 布局模式</div>
<div class="module-tab" onclick="switchModule(1)">💼 业务页面</div>
<div class="module-tab" onclick="switchModule(2)">🎨 CSS 工具类</div>
</div>
<div id="module0" class="module-content active">
<div class="category-grid" id="layoutGrid"></div>
</div>
<div id="module1" class="module-content">
<div class="category-grid" id="businessGrid"></div>
</div>
<div id="module2" class="module-content">
<div class="category-grid" id="cssGrid"></div>
</div>
<div id="noResult" class="hidden">
<div class="no-result">
<div class="no-result-icon">😕</div>
<div>没有找到匹配的内容</div>
</div>
</div>
<h2 class="section-title">📅 发展历程</h2>
<div class="timeline">
<div class="timeline-item">
<div class="timeline-year">2015</div>
<div class="timeline-content">
<strong>Table / Float 时代</strong> - Table 居中布局、浮动两栏/三栏布局、文本省略等基础 CSS 工具类,主要服务于银行系统项目
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2016</div>
<div class="timeline-content">
<strong>定位布局普及</strong> - 粘性定位、圣杯布局、颜色/边框工具类,电商平台和 IM 系统项目大量实践
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2017</div>
<div class="timeline-content">
<strong>Flexbox 革命</strong> - Flex 弹性布局普及,后台管理布局成为标配,间距/阴影工具类完善,企业/医院管理系统项目
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2018</div>
<div class="timeline-content">
<strong>CSS Grid 崛起</strong> - Grid 网格布局、瀑布流布局,Flexbox/动画工具类,教育/金融平台项目
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2019</div>
<div class="timeline-content">
<strong>响应式成熟</strong> - Sticky Footer、响应式工具类、栅格系统,物流/政务系统项目
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2020</div>
<div class="timeline-content">
<strong>数据可视化</strong> - Dashboard 仪表盘布局,数据大屏项目实践,HR 系统项目
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2021</div>
<div class="timeline-content">
<strong>移动端优先</strong> - 移动端自适应布局、rem 适配方案,H5 项目大量实践
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2022</div>
<div class="timeline-content">
<strong>CSS 变量时代</strong> - CSS 变量主题系统、暗色模式支持,工程化主题切换方案
</div>
</div>
<div class="timeline-item">
<div class="timeline-year">2024</div>
<div class="timeline-content">
<strong>容器查询时代</strong> - CSS Container Queries 容器查询,根据父容器尺寸自适应布局
</div>
</div>
</div>
<h2 class="section-title">📖 快速使用</h2>
<div class="usage-section">
<div class="usage-tabs">
<div class="usage-tab active" onclick="switchTab(0)">布局模式</div>
<div class="usage-tab" onclick="switchTab(1)">CSS 工具类</div>
</div>
<div class="usage-content active" id="usage0">
<p style="color:#606266;margin-bottom:10px;">直接参考布局模式的 HTML 结构,复制到你的项目中:</p>
<pre class="code-block"><code class="lang-html"><!-- Table 居中布局 -->
<table class="login-table">
<tr>
<td>
<div class="login-box">
<!-- 你的内容 -->
</div>
</td>
</tr>
</table></code></pre>
</div>
<div class="usage-content" id="usage1">
<p style="color:#606266;margin-bottom:10px;">在 HTML 中引入需要的 CSS 文件,直接使用类名:</p>
<pre class="code-block"><code class="lang-html"><link rel="stylesheet" href="css-utils/01-text.css">
<link rel="stylesheet" href="css-utils/05-spacing.css">
<div class="text-ellipsis m-2 p-3">
这是一段超长文本,超出部分会显示省略号...
</div></code></pre>
</div>
<div class="feature-list">
<div class="feature-item">纯原生 HTML/CSS</div>
<div class="feature-item">零依赖,开箱即用</div>
<div class="feature-item">20种经典布局模式</div>
<div class="feature-item">10个行业54个业务页面</div>
<div class="feature-item">10大类CSS工具类</div>
<div class="feature-item">完整注释,即学即用</div>
<div class="feature-item">全主流浏览器兼容</div>
<div class="feature-item">持续更新11年</div>
</div>
</div>
</div>
<div class="footer">
<p>wjs-web-application · wjs created by 2015 - 2026</p>
<p style="margin-top:8px;">
<a href="https://github.com/wjs-tech" target="_blank">GitHub @wjs-tech</a>
</p>
</div>
<script>
var layoutPatterns = [
{ id: 'table-center', name: 'Table 居中布局', icon: '📐', desc: '使用 table 实现垂直水平居中,兼容性极佳,适用于登录页等场景', path: 'layout-patterns/2015-table-center.html', year: '2015', tech: 'table 居中' },
{ id: 'float-two', name: '浮动左右两栏', icon: '📏', desc: 'float + margin 实现经典两列布局,左定宽右自适应', path: 'layout-patterns/2015-float-two-column.html', year: '2015', tech: 'float 布局' },
{ id: 'float-three', name: '浮动三栏布局', icon: '📊', desc: '左右定宽中间自适应,经典三栏布局方案', path: 'layout-patterns/2015-float-three-column.html', year: '2015', tech: '三栏布局' },
{ id: 'sticky', name: '粘性定位布局', icon: '📌', desc: 'position: sticky 实现顶部导航栏吸顶效果', path: 'layout-patterns/2016-position-sticky.html', year: '2016', tech: 'sticky 定位' },
{ id: 'holy-grail', name: '圣杯布局', icon: '🏆', desc: '负margin经典实现,中间列优先渲染的三栏布局', path: 'layout-patterns/2016-holy-grail.html', year: '2016', tech: '负margin' },
{ id: 'double-wing', name: '双飞翼布局', icon: '🪽', desc: '经典三栏布局变体,中间列优先渲染,负margin实现', path: 'layout-patterns/2016-double-wing.html', year: '2016', tech: '双飞翼' },
{ id: 'flex', name: 'Flex 弹性布局', icon: '🎯', desc: 'display: flex 现代布局方案,各种对齐轻松实现', path: 'layout-patterns/2017-flex-layout.html', year: '2017', tech: 'flexbox' },
{ id: 'admin', name: '后台管理布局', icon: '🏢', desc: '左侧固定菜单 + 顶部导航 + 右侧内容区,经典后台布局', path: 'layout-patterns/2017-admin-aside.html', year: '2017', tech: '左侧菜单' },
{ id: 'percentage', name: '百分比自适应', icon: '📊', desc: '全百分比宽度布局,响应式设计雏形', path: 'layout-patterns/2017-percentage-adaptive.html', year: '2017', tech: '百分比布局' },
{ id: 'grid', name: 'Grid 网格布局', icon: '🔲', desc: 'display: grid 二维布局,复杂网格轻松搞定', path: 'layout-patterns/2018-grid-layout.html', year: '2018', tech: 'CSS Grid' },
{ id: 'waterfall', name: '卡片瀑布流', icon: '🃏', desc: 'column-count 实现多列瀑布流布局,图片墙效果', path: 'layout-patterns/2018-card-waterfall.html', year: '2018', tech: 'column-count' },
{ id: 'equal-height', name: '等高列布局', icon: '📏', desc: '多列等高效果,padding+margin抵消法 / flex实现', path: 'layout-patterns/2018-equal-height-columns.html', year: '2018', tech: '等高列' },
{ id: 'sticky-footer', name: 'Sticky Footer', icon: '🦶', desc: '底部粘滞布局,内容不足时footer也在页面底部', path: 'layout-patterns/2019-sticky-footer.html', year: '2019', tech: 'sticky footer' },
{ id: 'nine-grid', name: '九宫格布局', icon: '🔲', desc: '3x3九宫格,grid/flex实现,常见于移动端', path: 'layout-patterns/2019-nine-grid.html', year: '2019', tech: '九宫格' },
{ id: 'dashboard', name: 'Dashboard 布局', icon: '📈', desc: '数据大屏分块布局,上下左右多区域划分', path: 'layout-patterns/2020-dashboard.html', year: '2020', tech: '网格分块' },
{ id: 'sandwich', name: '三明治布局', icon: '🥪', desc: 'Header/Content/Footer 经典上中下三段式布局', path: 'layout-patterns/2020-sandwich-layout.html', year: '2020', tech: '三段式' },
{ id: 'mobile', name: '移动端自适应', icon: '📱', desc: 'rem + flex 移动端适配方案,响应式设计', path: 'layout-patterns/2021-mobile-adaptive.html', year: '2021', tech: 'rem + flex' },
{ id: 'accordion', name: '手风琴折叠', icon: '🪗', desc: '可展开收起的手风琴折叠面板布局', path: 'layout-patterns/2021-accordion.html', year: '2021', tech: '折叠面板' },
{ id: 'css-var-theme', name: 'CSS变量主题', icon: '🎨', desc: '支持明暗主题切换的页面布局,CSS变量实现', path: 'layout-patterns/2022-css-variable-theme.html', year: '2022', tech: '主题切换' },
{ id: 'container-queries', name: '容器查询布局', icon: '📦', desc: '现代CSS容器查询,根据父容器尺寸自适应', path: 'layout-patterns/2024-container-queries.html', year: '2024', tech: 'Container Queries' }
];
var businessPages = [
{ id: 'banking', name: '银行网银系统', icon: '🏦', desc: '登录页、账户总览、转账汇款、交易记录等', path: 'business-pages/01-banking/', year: '2015', count: '8 个页面' },
{ id: 'ecommerce', name: '电商平台', icon: '🛒', desc: '商品列表、商品详情、购物车、订单确认等', path: 'business-pages/02-ecommerce/', year: '2016', count: '7 个页面' },
{ id: 'im', name: 'IM 即时通讯', icon: '💬', desc: '登录、主界面、联系人列表、群聊页面', path: 'business-pages/03-im-system/', year: '2016', count: '4 个页面' },
{ id: 'enterprise', name: '企业管理系统', icon: '🏭', desc: '管理布局、用户管理、角色权限、数据仪表盘', path: 'business-pages/04-enterprise/', year: '2017', count: '4 个页面' },
{ id: 'hospital', name: '医院管理系统', icon: '🏥', desc: '门诊排队、患者病历、医生排班、药房发药等', path: 'business-pages/05-hospital/', year: '2017', count: '6 个页面' },
{ id: 'education', name: '教育学习平台', icon: '📚', desc: '课程列表、课程详情、在线考试、学习报告', path: 'business-pages/06-education/', year: '2018', count: '4 个页面' },
{ id: 'finance', name: '金融理财平台', icon: '💰', desc: '理财首页、产品详情、我的资产、充值提现等', path: 'business-pages/07-finance/', year: '2018', count: '7 个页面' },
{ id: 'logistics', name: '物流管理系统', icon: '🚚', desc: '物流追踪、仓库管理、运单管理、调度中心等', path: 'business-pages/08-logistics/', year: '2019', count: '6 个页面' },
{ id: 'government', name: '政务服务系统', icon: '🏛️', desc: '政务首页、审批列表、审批详情、公告通知', path: 'business-pages/09-government/', year: '2019', count: '4 个页面' },
{ id: 'hr', name: 'HR 人力资源', icon: '👥', desc: '员工列表、考勤管理、薪资管理、招聘管理', path: 'business-pages/10-hr-system/', year: '2020', count: '4 个页面' }
];
var cssUtils = [
{ id: 'text', name: '文本工具类', icon: '📝', desc: '文本省略、对齐、换行、大小写、字重、字号', path: 'css-utils/01-text.css', year: '2015', count: '30+ 类' },
{ id: 'layout', name: '布局工具类', icon: '📐', desc: '浮动、显示、可见性、定位、溢出、宽高', path: 'css-utils/02-layout.css', year: '2015', count: '25+ 类' },
{ id: 'color', name: '颜色工具类', icon: '🎨', desc: '文字色、背景色、边框色、主题变量', path: 'css-utils/03-color.css', year: '2016', count: '20+ 类' },
{ id: 'border', name: '边框工具类', icon: '🔲', desc: '边框、圆角、边框样式全方位控制', path: 'css-utils/04-border.css', year: '2016', count: '20+ 类' },
{ id: 'spacing', name: '间距工具类', icon: '📏', desc: 'margin、padding 全方位,0-5级间距', path: 'css-utils/05-spacing.css', year: '2017', count: '50+ 类' },
{ id: 'shadow', name: '阴影工具类', icon: '🌑', desc: '盒子阴影、文字阴影,多尺寸层级', path: 'css-utils/06-shadow.css', year: '2017', count: '10+ 类' },
{ id: 'flexbox', name: 'Flexbox 工具', icon: '🎯', desc: 'flex 布局全套工具类,对齐、方向、换行', path: 'css-utils/07-flexbox.css', year: '2018', count: '40+ 类' },
{ id: 'animation', name: '动画工具类', icon: '✨', desc: '过渡、关键帧、变换、悬停效果', path: 'css-utils/08-animation.css', year: '2018', count: '15+ 类' },
{ id: 'responsive', name: '响应式工具', icon: '📱', desc: '断点显隐、12列栅格、容器类', path: 'css-utils/09-responsive.css', year: '2019', count: '30+ 类' },
{ id: 'variables', name: 'CSS 变量主题', icon: '🎭', desc: '主题色、字体、间距、圆角、暗色模式变量', path: 'css-utils/10-css-variables.css', year: '2022', count: '50+ 变量' }
];
function renderLayouts(filter) {
var grid = document.getElementById('layoutGrid');
var html = '';
var data = filter ? layoutPatterns.filter(function(item) {
return item.name.indexOf(filter) > -1 || item.desc.indexOf(filter) > -1 || item.tech.indexOf(filter) > -1;
}) : layoutPatterns;
data.forEach(function(item) {
html += '<a class="category-card" href="' + item.path + '" target="_blank">';
html += '<div class="category-icon">' + item.icon + '</div>';
html += '<div class="category-title">' + item.name + '<span class="arrow">→</span></div>';
html += '<div class="category-desc">' + item.desc + '</div>';
html += '<div class="category-meta"><span class="category-count">' + item.tech + '</span><span class="category-year">' + item.year + '</span></div>';
html += '</a>';
});
grid.innerHTML = html;
return data.length;
}
function renderBusiness(filter) {
var grid = document.getElementById('businessGrid');
var html = '';
var data = filter ? businessPages.filter(function(item) {
return item.name.indexOf(filter) > -1 || item.desc.indexOf(filter) > -1;
}) : businessPages;
data.forEach(function(item) {
html += '<a class="category-card" href="' + item.path + '" target="_blank">';
html += '<div class="category-icon">' + item.icon + '</div>';
html += '<div class="category-title">' + item.name + '<span class="arrow">→</span></div>';
html += '<div class="category-desc">' + item.desc + '</div>';
html += '<div class="category-meta"><span class="category-count">' + item.count + '</span><span class="category-year">' + item.year + '</span></div>';
html += '</a>';
});
grid.innerHTML = html;
return data.length;
}
function renderCss(filter) {
var grid = document.getElementById('cssGrid');
var html = '';
var data = filter ? cssUtils.filter(function(item) {
return item.name.indexOf(filter) > -1 || item.desc.indexOf(filter) > -1;
}) : cssUtils;
data.forEach(function(item) {
html += '<a class="category-card" href="' + item.path + '" target="_blank">';
html += '<div class="category-icon">' + item.icon + '</div>';
html += '<div class="category-title">' + item.name + '<span class="arrow">→</span></div>';
html += '<div class="category-desc">' + item.desc + '</div>';
html += '<div class="category-meta"><span class="category-count">' + item.count + '</span><span class="category-year">' + item.year + '</span></div>';
html += '</a>';
});
grid.innerHTML = html;
return data.length;
}
var currentModule = 0;
function switchModule(index) {
currentModule = index;
var tabs = document.querySelectorAll('.module-tab');
var contents = document.querySelectorAll('.module-content');
tabs.forEach(function(tab, i) {
tab.classList.toggle('active', i === index);
});
contents.forEach(function(content, i) {
content.classList.toggle('active', i === index);
});
handleSearch();
}
function handleSearch() {
var keyword = document.getElementById('searchInput').value.trim();
var noResult = document.getElementById('noResult');
var count = 0;
if (currentModule === 0) {
count = renderLayouts(keyword);
} else if (currentModule === 1) {
count = renderBusiness(keyword);
} else {
count = renderCss(keyword);
}
noResult.classList.toggle('hidden', count > 0);
}
function switchTab(index) {
var tabs = document.querySelectorAll('.usage-tab');
var contents = document.querySelectorAll('.usage-content');
tabs.forEach(function(tab, i) {
tab.classList.toggle('active', i === index);
});
contents.forEach(function(content, i) {
content.classList.toggle('active', i === index);
});
}
function highlightHTML(code) {
var pattern = new RegExp(
'(<!--[\\s\\S]*?-->)' +
'|(<\\/?)([a-zA-Z][\\w-]*)' +
'|(\\s)([a-zA-Z-]+)(=)' +
'|(=)("[^"]*"|\'[^\']*\')' +
'|(>)',
'g'
);
return code.replace(pattern, function(m, cm, tagStart, tagName, sp, attr, eq, eq2, val, gt) {
if (cm) return '<span class="cm">' + m + '</span>';
if (tagStart && tagName) return tagStart + '<span class="tag">' + tagName + '</span>';
if (sp && attr && eq) return sp + '<span class="attr">' + attr + '</span>' + eq;
if (eq2 && val) return eq2 + '<span class="str">' + val + '</span>';
if (gt) return '<span class="tag">' + gt + '</span>';
return m;
});
}
function highlightCodeBlocks() {
var blocks = document.querySelectorAll('.code-block code');
blocks.forEach(function(block) {
var lang = block.className || '';
var code = block.innerHTML;
if (lang.indexOf('lang-html') > -1) {
block.innerHTML = highlightHTML(code);
}
});
}
renderLayouts();
renderBusiness();
renderCss();
highlightCodeBlocks();
</script>
</body>
</html>