Skip to content

Commit 9728ec1

Browse files
committed
Mobile tables: convert to stacked card layout instead of horizontal scroll
- Tables automatically transform to vertical card layout on mobile (<768px) - Each row becomes a card with label-value pairs - No more horizontal scrolling needed - Applied to guide articles, docs param tables, and pricing comparison
1 parent 1f2feba commit 9728ec1

File tree

4 files changed

+54
-34
lines changed

4 files changed

+54
-34
lines changed

docs.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,26 @@
8181

8282
/* Responsive table wrapper */
8383
.doc-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:16px 0 24px;
84-
border:1px solid var(--border);border-radius:var(--r);position:relative}
85-
.doc-table-wrap::after{content:'← 左右滑动查看 →';display:none;position:absolute;top:-22px;right:0;
86-
font-size:.7rem;color:var(--text-muted);pointer-events:none}
87-
.doc-table-wrap table{margin:0;border:none}
88-
.doc-table-wrap th:first-child,.doc-table-wrap td:first-child{position:sticky;left:0;
89-
background:var(--card);z-index:1}
84+
border-radius:var(--r);position:relative}
85+
.doc-table-wrap table{margin:0}
9086

9187
@media(max-width:768px){
9288
.doc-layout{grid-template-columns:1fr;gap:20px}
9389
.doc-sidebar{position:static;display:flex;flex-wrap:wrap;gap:4px}
9490
.doc-sidebar a{border-left:none;border-bottom:2px solid var(--border);padding:6px 12px}
9591
.doc-sidebar .sb-title{display:none}
96-
.doc-table-wrap::after{display:block}
97-
.doc-content .param-table,.doc-content .media-table{font-size:.78rem}
98-
.doc-content .param-table th,.doc-content .param-table td,
99-
.doc-content .media-table th,.doc-content .media-table td{padding:7px 10px}
100-
.doc-content .param-table td:first-child{white-space:normal;word-break:break-all}
92+
93+
.doc-content table.resp-cards{border:none}
94+
.doc-content table.resp-cards thead{display:none}
95+
.doc-content table.resp-cards tr{display:block;margin-bottom:12px;border:1px solid var(--border);
96+
border-radius:var(--r);overflow:hidden;background:var(--card)}
97+
.doc-content table.resp-cards td{display:flex;justify-content:space-between;align-items:flex-start;
98+
gap:10px;padding:8px 12px;border:none;border-bottom:1px solid var(--border);font-size:.82rem}
99+
.doc-content table.resp-cards td:last-child{border-bottom:none}
100+
.doc-content table.resp-cards td::before{content:attr(data-label);font-weight:700;color:var(--text);
101+
flex-shrink:0;min-width:30%;font-size:.78rem}
102+
.doc-content table.resp-cards td:first-child{background:var(--bg3);font-family:var(--mono);
103+
color:var(--accent2);font-size:.8rem}
101104
}
102105
</style>
103106
<script type="application/ld+json">

guides/guide.css

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
.guide-body table{width:100%;border-collapse:collapse;margin:16px 0;font-size:.85rem}
2727
.guide-body th,.guide-body td{border:1px solid var(--border);padding:10px 14px;text-align:left}
2828
.guide-body th{background:var(--bg3);color:var(--text);font-weight:600}
29-
/* Responsive table wrapper (added by JS) */
30-
.guide-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:16px 0;
31-
border-radius:var(--r);position:relative}
32-
.guide-table-wrap table{margin:0}
33-
.guide-table-wrap::after{content:'← 左右滑动查看 →';display:none;position:absolute;top:-20px;right:0;
34-
font-size:.7rem;color:var(--text-muted);pointer-events:none}
3529
.guide-body a{color:var(--red);text-decoration:none}
3630
.guide-body a:hover{text-decoration:underline}
3731
.guide-body ul,.guide-body ol{padding-left:24px;margin:0 0 1em}
@@ -56,14 +50,23 @@
5650
transition:color .2s}
5751
.mac-term-expand:hover{color:var(--red)}
5852

53+
/* Mobile: table → stacked card layout */
5954
@media(max-width:768px){
6055
.guide-article{padding:70px 0 40px}
6156
.guide-body{font-size:.86rem}
6257
.guide-body pre{font-size:.78rem;padding:12px}
63-
.guide-body table{font-size:.78rem}
64-
.guide-body th,.guide-body td{padding:7px 8px}
65-
.guide-table-wrap::after{display:block}
66-
.guide-table-wrap td:first-child{position:sticky;left:0;background:var(--bg2);z-index:1}
58+
59+
.guide-body table.resp-cards{border:none}
60+
.guide-body table.resp-cards thead{display:none}
61+
.guide-body table.resp-cards tr{display:block;margin-bottom:12px;border:1px solid var(--border);
62+
border-radius:var(--r);overflow:hidden;background:var(--card)}
63+
.guide-body table.resp-cards td{display:flex;justify-content:space-between;align-items:flex-start;
64+
gap:10px;padding:8px 12px;border:none;border-bottom:1px solid var(--border);font-size:.82rem}
65+
.guide-body table.resp-cards td:last-child{border-bottom:none}
66+
.guide-body table.resp-cards td::before{content:attr(data-label);font-weight:700;color:var(--text);
67+
flex-shrink:0;min-width:35%;font-size:.78rem}
68+
.guide-body table.resp-cards td:only-child::before{display:none}
69+
6770
.guide-cta{padding:20px 16px!important}
6871
.guide-cta div:last-child{flex-direction:column}
6972
.guide-cta a{justify-content:center}

js/shared.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,18 @@ document.addEventListener('DOMContentLoaded', () => {
220220
}
221221
});
222222

223-
// Auto-wrap tables in scrollable containers (guides + docs)
224-
document.querySelectorAll('.guide-body table, .doc-content .param-table, .doc-content .media-table').forEach(table => {
225-
if (table.closest('.guide-table-wrap') || table.closest('.doc-table-wrap') || table.closest('.cmp-wrap')) return;
226-
const wrapper = document.createElement('div');
227-
wrapper.className = table.closest('.guide-body') ? 'guide-table-wrap' : 'doc-table-wrap';
228-
table.parentNode.insertBefore(wrapper, table);
229-
wrapper.appendChild(table);
223+
// Responsive table cards: add data-label to td, add resp-cards class
224+
document.querySelectorAll('.guide-body table, .doc-content .param-table, .doc-content .media-table, .cmp-table').forEach(table => {
225+
const headers = [];
226+
table.querySelectorAll('thead th').forEach(th => headers.push(th.textContent.trim()));
227+
if (headers.length < 2) return;
228+
table.querySelectorAll('tbody tr').forEach(tr => {
229+
if (tr.classList.contains('cmp-cat')) return;
230+
tr.querySelectorAll('td').forEach((td, i) => {
231+
if (headers[i]) td.setAttribute('data-label', headers[i]);
232+
});
233+
});
234+
table.classList.add('resp-cards');
230235
});
231236

232237
// Docs scroll spy

pricing.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
/* COMPARISON TABLE */
6060
.pr-compare{padding:50px 0 40px}
6161
.cmp-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
62-
.cmp-table{width:100%;border-collapse:separate;border-spacing:0;min-width:680px}
62+
.cmp-table{width:100%;border-collapse:separate;border-spacing:0}
6363
.cmp-table th,.cmp-table td{padding:14px 18px;text-align:left;font-size:.85rem;border-bottom:1px solid var(--border)}
6464
.cmp-table thead th{background:var(--bg3);color:var(--text);font-weight:700;position:sticky;top:0;z-index:1}
6565
.cmp-table thead th:first-child{border-radius:var(--r) 0 0 0}
@@ -113,11 +113,20 @@
113113

114114
@media(max-width:768px){
115115
.plans-grid{grid-template-columns:1fr}
116-
.cmp-table{min-width:480px}
117-
.cmp-table th,.cmp-table td{padding:10px 12px;font-size:.78rem}
118-
.cmp-table thead th{position:sticky;left:0}
119-
.cmp-table tbody td:first-child{position:sticky;left:0;background:var(--bg2);z-index:1;font-weight:600}
120-
.cmp-hint{display:block}
116+
.cmp-wrap{overflow:visible}
117+
.cmp-table.resp-cards{border-spacing:0}
118+
.cmp-table.resp-cards thead{display:none}
119+
.cmp-table.resp-cards .cmp-cat{display:none}
120+
.cmp-table.resp-cards tr{display:block;margin-bottom:12px;border:1px solid var(--border);
121+
border-radius:var(--r);overflow:hidden;background:var(--card)}
122+
.cmp-table.resp-cards td{display:flex;justify-content:space-between;align-items:center;
123+
padding:10px 14px;border-bottom:1px solid var(--border);font-size:.84rem}
124+
.cmp-table.resp-cards td:last-child{border-bottom:none}
125+
.cmp-table.resp-cards td::before{content:attr(data-label);font-weight:600;color:var(--text);
126+
flex-shrink:0;font-size:.82rem}
127+
.cmp-table.resp-cards td:first-child{background:var(--bg3);font-weight:700;color:var(--text)}
128+
.cmp-table.resp-cards td:first-child::before{display:none}
129+
.cmp-hint{display:none}
121130
.pr-cta-box{padding:36px 24px}
122131
}
123132
</style>

0 commit comments

Comments
 (0)