Overlay scrollbars via OverlayScrollbars

overflow: overlay is dead in current Chromium, so an appearing native
scrollbar shifted the layout again. OverlayScrollbars replaces it with
floating auto-hiding scrollbars that never reserve space (native window
scroll APIs unaffected on a body target). Themed via --os-* variables in
pagerite.css; the html scrollbar-color styling stays as no-JS fallback.
(package-lock.json is gitignored.)
This commit is contained in:
2026-08-18 20:30:08 +00:00
parent 7f140001fa
commit a75ad6f5da
4 changed files with 29 additions and 21 deletions
+12 -21
View File
@@ -67,31 +67,22 @@
html {
scroll-behavior: smooth;
/* Overlay scrollbars where supported (Chromium/WebKit, deprecated but
working): a scrollbar that appears covers a strip of the layout instead
of shifting it, and no space is reserved while absent — so 100vw always
equals the body width and .wide breakout margins stay exact. Ignored by
Firefox (unknown value), which keeps its thin classic scrollbar. */
overflow-y: overlay;
/* Lightweight scrollbar styling: thin, theme-muted thumb on a transparent
track where supported (Firefox: the two properties; WebKit: the rules
below). Full restyling deliberately not attempted. */
/* Native-scrollbar fallback styling (JS off or before pagerite.js runs):
thin, theme-muted thumb on a transparent track. With JS the scrollbars
are replaced by OverlayScrollbars (see pagerite.js) — floating,
auto-hidden scrollbars styled by the --os-* variables below, so they
never reserve layout space or shift the page when appearing. */
scrollbar-width: thin;
scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}
::-webkit-scrollbar {
width: 0.5rem;
height: 0.5rem;
}
::-webkit-scrollbar-thumb {
background: color-mix(in srgb, var(--muted) 45%, transparent);
border-radius: 0.25rem;
}
::-webkit-scrollbar-track {
background: transparent;
.os-scrollbar {
--os-size: 0.5rem;
--os-thumb-bg: color-mix(in srgb, var(--muted) 45%, transparent);
--os-thumb-hover-bg: color-mix(in srgb, var(--muted) 65%, transparent);
--os-thumb-active-bg: var(--muted);
--os-track-bg: transparent;
--os-thumb-border-radius: 0.25rem;
}
body {