Skip to content

Commit b1d6741

Browse files
Oleksandr Redkogopherbot
authored andcommitted
_content/blog/swisstable: fix tables display
Fixes golang/go#79915 Change-Id: I3b0f2026b3b7d7ade086e4329c88ac203207b9c6 Reviewed-on: https://go-review.googlesource.com/c/website/+/788720 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Commit-Queue: Hyang-Ah Hana Kim <hyangah@gmail.com>
1 parent b44c933 commit b1d6741

1 file changed

Lines changed: 46 additions & 16 deletions

File tree

_content/blog/swisstable.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,65 @@ The values are not shown, as they are not relevant to this example.
4747

4848
<style>
4949
/*
50-
go.dev .Article max-width is 55em. Only enable horizontal scrolling if the
51-
screen is narrow enough to require scrolling (narrower than article width)
52-
because otherwise some platforms (e.g., Chrome on macOS) display a scrollbar
53-
even when the screen is wide enough.
50+
Keep the table within the prose column. overflow-x: auto adds a horizontal
51+
scrollbar only when the table is wider than the column (e.g. on narrow
52+
viewports), so the right columns are never clipped.
5453
*/
55-
@media screen and (max-width: 55em) {
56-
.swisstable-table-container {
57-
/* Scroll horizontally on overflow (likely on mobile) */
58-
overflow: scroll;
59-
}
54+
.swisstable-table-container {
55+
overflow-x: auto;
6056
}
6157

6258
.swisstable-table {
63-
/* Combine table inner borders (1px total rather than 2px, one for cell above and one for cell below. */
59+
/* Combine table inner borders (1px total rather than 2px, one for the cell above and one for the cell below). */
6460
border-collapse: collapse;
65-
/* All column widths equal. */
61+
/* Fixed layout: the data columns share the remaining width equally after the
62+
wider first (label) column below. */
6663
table-layout: fixed;
67-
/* Center table within container div */
68-
margin: 0 auto;
64+
/* Match the width of the surrounding text column. */
65+
width: 100%;
66+
/*
67+
Keep columns comfortable on phones (scroll instead of squishing them).
68+
Computed as 3em label + 16 data columns at ~2.5em each. Not max-content:
69+
with fixed layout that is derived from the first row, so the colspan header
70+
rows of the group/control-word tables would shrink the data columns.
71+
*/
72+
min-width: 44em;
6973
}
7074

71-
.swisstable-table-cell {
75+
/*
76+
The descendant selector raises specificity above the site-wide
77+
"div.markdown th, div.markdown td" rule, which otherwise overrides the padding
78+
below with a wide 2em horizontal padding and stretches the cells.
79+
*/
80+
.swisstable-table .swisstable-table-cell {
7281
/* Black border between cells. */
7382
border: 1px solid;
7483
/* Add visual spacing around contents. */
75-
padding: 0.5em 1em 0.5em 1em;
84+
padding: 0.5em 0.6em 0.5em 0.6em;
7685
/* Center within cell. */
7786
text-align: center;
7887
}
88+
89+
/* Give the label column ("Slot", "Key", "h2") slightly more room than the data columns. */
90+
.swisstable-table .swisstable-table-cell:first-child {
91+
width: 3em;
92+
}
93+
94+
/*
95+
The SIMD comparison table has long row labels ("Comparison", "Control word"), so
96+
its rules below override the base .swisstable-table widths above (equal
97+
specificity, later in source order wins).
98+
99+
Same data-column width as the other tables: 8em label + 8 data columns at ~2.5em each.
100+
*/
101+
.swisstable-table-simd-comparison {
102+
min-width: 28em;
103+
}
104+
105+
/* Widen the first column to at least the largest label so it isn't clipped. */
106+
.swisstable-table-simd-comparison .swisstable-table-cell:first-child {
107+
width: 8em;
108+
}
79109
</style>
80110

81111
<div class="swisstable-table-container">
@@ -293,7 +323,7 @@ For example, if we are looking for key 32, where `h2 = 89`, the operation we wan
293323

294324
<!-- Visualization of SIMD comparison -->
295325
<div class="swisstable-table-container">
296-
<table class="swisstable-table">
326+
<table class="swisstable-table swisstable-table-simd-comparison">
297327
<tbody>
298328
<tr>
299329
<td class="swisstable-table-cell"><strong>Test word</strong></td>

0 commit comments

Comments
 (0)