3 ms·
In your styles: > pre { overflow-x: scroll; } `overflow: scroll` is very poorly named, and practically never the right tool. You want `overflow: auto` instead
by chrismorgan 4y ago
In your styles:
> pre { overflow-x: scroll; }
`overflow: scroll` is very poorly named, and practically never the right tool. You want `overflow: auto` instead, which only renders scrollbars if they’re needed.
(Long ago, there were two potentially valid scenarios for it: for avoiding reflow when changing the document’s length, and for unbreaking viewport units so that 100vw includes the viewport’s vertical scrollbar. The former was only exceedingly rarely useful, and can be achieved better now on all but Safari with the scrollbar-gutter property. The latter only Firefox ever implemented, and no one else wanted to, so they eventually removed it from the spec and from Firefox, so now viewport units are just stupidly broken by design. I myself have not found a single place I wanted to use `overflow: scroll` or where it would have been reasonable in the past decade. Stylesheet linters should include a default rule that complains about `overflow: scroll` because it’s so temptingly-named but so thoroughly not what you want.)
- layer8 4y agoIt’s the right tool when you prefer scrollbars to always be rendered, which is a valid preference. For example, in the “not needed” case, the scrollbar being rendered tells you at a glance that there’s no scrollable content with a hidden “only appears upon movement” scrollbar, an information which would otherwise be missing.
- chrismorgan 4y agoI’m completely confused by what you write, because it seems back-to-front. You seem to be speaking of platforms with overlay scrollbars that are invisible until you try scrolling; how does `overflow: scroll` behave differently from `overflow: auto` on such platforms? I would expect it to either be no different, or possibly to briefly show a completely misleading scrollbar briefly when the content appears. I think I must be missing something. Can you explain more what you mean?
- deleted 4y ago[deleted]