Skip to content

Commit bd87faa

Browse files
authored
Fix table overflow issue. Add fixed-table class (GoogleChrome#335)
1 parent 056df15 commit bd87faa

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

site/_includes/macros/reference.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#}
55
{% macro renderReferenceTable(all, channel) %}
66

7-
<table class="reference">
7+
<table class="reference fixed-table width-full">
88
<thead>
99
<tr>
1010
<th>Name</th>

site/_scss/_reset.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ select {
7171
word-spacing: inherit;
7272
}
7373

74-
// Remove the whitespace between table cells
75-
table {
76-
border-collapse: collapse;
77-
}
78-
7974
// Remove the default border on iframes
8075
iframe {
8176
border: 0;
@@ -87,11 +82,6 @@ img:not([alt]) {
8782
filter: blur(10px);
8883
}
8984

90-
// Always place table captions on the bottom.
91-
caption {
92-
caption-side: bottom;
93-
}
94-
9585
// Define a basic hairline element.
9686
hr {
9787
height: 1px;

site/_scss/blocks/_table.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818

1919
table {
2020
border: 1px solid var(--color-hairline);
21-
display: block;
21+
border-collapse: collapse;
2222
margin-left: auto;
2323
margin-right: auto;
24-
max-width: fit-content;
25-
overflow-x: auto;
24+
overflow-x: scroll;
2625
}
2726

2827
th {
@@ -41,5 +40,6 @@ tr:only-of-type {
4140

4241
caption {
4342
border-top: 1px solid var(--color-hairline);
43+
caption-side: bottom;
4444
padding: get-size(300);
4545
}

site/_transforms/tables.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* will be modified in place.
66
*/
77
const tables = $ => {
8-
$('table').each((_, elem) => {
8+
$('table:not(.fixed-table)').each((_, elem) => {
99
const $elem = $(elem);
1010
$elem.replaceWith(`<div class="responsive-table">${$elem}</div>`);
1111
});

site/en/style-guide/index.njk

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,36 @@ title: Style guide
164164
</tbody>
165165
</table>
166166

167+
<table class="fixed-table width-full">
168+
<tbody>
169+
<tr>
170+
<th>Person</th>
171+
<th>Number</th>
172+
<th>Third Column</th>
173+
</tr>
174+
<tr>
175+
<td>Someone Lastname</td>
176+
<td>900</td>
177+
<td>Nullam quis risus eget urna mollis ornare vel eu leo.</td>
178+
</tr>
179+
<tr>
180+
<td><a href="#">Person Name</a></td>
181+
<td>1200</td>
182+
<td>Vestibulum id ligula porta felis euismod semper. Donec ullamcorper nulla non metus auctor fringilla.</td>
183+
</tr>
184+
<tr>
185+
<td>Another Person</td>
186+
<td>1500</td>
187+
<td>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Nullam id dolor id nibh ultricies vehicula ut id elit.</td>
188+
</tr>
189+
<tr>
190+
<td>Last One</td>
191+
<td>2800</td>
192+
<td>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</td>
193+
</tr>
194+
</tbody>
195+
</table>
196+
167197
<dl>
168198
<dt>Definition List Title</dt>
169199
<dd>Definition list division.</dd>

0 commit comments

Comments
 (0)