From 9d14fe09838c7cf83edd5eb81ca0ce021b9f2de3 Mon Sep 17 00:00:00 2001 From: ngocanhnckh <12997699+ngocanhnckh@users.noreply.github.com> Date: Mon, 23 Nov 2026 00:25:18 +0700 Subject: [PATCH] [site] Let docs tables scroll horizontally instead of overflowing on narrow screens Tables in docs pages can contain content that cannot wrap (code, long identifiers), so on narrow viewports they were wider than the article and either stretched the page or were cut off. Make top-level tables horizontally scrollable, sized to their content and capped at the article width. Tables with a .wide-cell still fill the article. Fixes #1293 --- packages/lit-dev-content/site/css/docs.css | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/lit-dev-content/site/css/docs.css b/packages/lit-dev-content/site/css/docs.css index 908b565d6..a485d2658 100644 --- a/packages/lit-dev-content/site/css/docs.css +++ b/packages/lit-dev-content/site/css/docs.css @@ -306,6 +306,23 @@ table { background-color: var(--sys-color-surface-container-dim); } +/* Tables can contain content that can't wrap (e.g. code), so let them scroll + horizontally instead of overflowing the article on narrow viewports. Sizing + to max-content keeps tables that fit as wide as their content. Tables nested + inside another table's cell are left alone. */ +table:not(:is(td, th) table) { + display: block; + width: max-content; + max-width: 100%; + overflow-x: auto; +} + +/* Tables with a .wide-cell fill the article, as they do without the rule + above. */ +table:has(.wide-cell) { + width: 100%; +} + th { background-color: var(--sys-color-surface-container-highest); text-align: left;