Skip to content

Commit ebc4792

Browse files
Improved HTML table rendering
fixes #17
1 parent c060944 commit ebc4792

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

assets/built/screen.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/built/screen.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/built/source.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/built/source.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/screen.css

+20-29
Original file line numberDiff line numberDiff line change
@@ -2204,51 +2204,42 @@ unless a heading is the very first element in the post content */
22042204
border: 0;
22052205
}
22062206

2207-
.gh-content table:not(.gist table) {
2208-
display: inline-block;
2209-
width: auto;
2210-
max-width: 100%;
2211-
overflow-x: auto;
2207+
.gh-content .gh-table {
2208+
overflow-x: scroll;
2209+
-webkit-overflow-scrolling: touch;
2210+
}
2211+
2212+
.gh-content .gh-table table {
2213+
width: 100%;
22122214
font-family: var(--font-sans);
2213-
font-size: 1.6rem;
2215+
font-size: 1.5rem;
22142216
white-space: nowrap;
22152217
vertical-align: top;
22162218
border-spacing: 0;
22172219
border-collapse: collapse;
2218-
-webkit-overflow-scrolling: touch;
2219-
background: radial-gradient(ellipse at left, rgb(0 0 0 / 0.2) 0%, rgb(0 0 0 / 0) 75%) 0 center, radial-gradient(ellipse at right, rgb(0 0 0 / 0.2) 0%, rgb(0 0 0 / 0) 75%) 100% center;
2220-
background-repeat: no-repeat;
2221-
background-attachment: scroll, scroll;
2222-
background-size: 10px 100%, 10px 100%;
22232220
}
22242221

2225-
.gh-content table:not(.gist table) td:first-child {
2226-
background-image: linear-gradient(to right, rgb(255 255 255 / 1) 50%, rgb(255 255 255 / 0) 100%);
2227-
background-repeat: no-repeat;
2228-
background-size: 20px 100%;
2229-
}
2230-
2231-
.gh-content table:not(.gist table) td:last-child {
2232-
background-image: linear-gradient(to left, rgb(255 255 255 / 1) 50%, rgb(255 255 255 / 0) 100%);
2233-
background-repeat: no-repeat;
2234-
background-position: 100% 0;
2235-
background-size: 20px 100%;
2236-
}
2237-
2238-
.gh-content table:not(.gist table) th {
2222+
.gh-content .gh-table table th {
22392223
font-size: 1.2rem;
22402224
font-weight: 700;
22412225
color: var(--color-darkgrey);
22422226
text-align: left;
22432227
text-transform: uppercase;
22442228
letter-spacing: 0.2px;
2245-
background-color: var(--color-white);
22462229
}
22472230

2248-
.gh-content table:not(.gist table) th,
2249-
.gh-content table:not(.gist table) td {
2231+
.gh-content .gh-table table :is(th, td),
2232+
.gh-content .gh-table table td {
22502233
padding: 6px 12px;
2251-
border: 1px solid var(--color-light-gray);
2234+
border-bottom: 1px solid var(--color-border);
2235+
}
2236+
2237+
.gh-content .gh-table table :is(th, td):first-child {
2238+
padding-left: 0;
2239+
}
2240+
2241+
.gh-content .gh-table table :is(th, td):last-child {
2242+
padding-right: 0;
22522243
}
22532244

22542245
/* 16. Cards

assets/js/main.js

+12
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,16 @@
4545
if (!document.body.classList.contains('home-template') && !document.body.classList.contains('post-template')) {
4646
pagination();
4747
}
48+
})();
49+
50+
/* Responsive HTML table */
51+
(function () {
52+
const tables = document.querySelectorAll('.gh-content > table:not(.gist table)');
53+
const wrapper = document.createElement('div');
54+
wrapper.className = 'gh-table';
55+
56+
tables.forEach(function (table) {
57+
table.parentNode.insertBefore(wrapper, table);
58+
wrapper.appendChild(table);
59+
});
4860
})();

0 commit comments

Comments
 (0)