diff --git a/snippets/hide-scrollbars.md b/snippets/hide-scrollbars.md new file mode 100644 index 000000000..b6301a743 --- /dev/null +++ b/snippets/hide-scrollbars.md @@ -0,0 +1,35 @@ +--- +title: Hide scroll bars +tags: visual +expertise: intermediate +author: chalarangelo +firstSeen: 2022-05-13T05:00:00-04:00 +--- + +Hides scrollbars on an element, while still allowing it to be scrollable. + +- Use `overflow: auto` to allow the element to be scrollable. +- Use `scrollbar-width: none` to hide scrollbars on Firefox. +- Use `display: none` on the `::-webkit-scrollbar` pseudo-element to hide scrollbars on WebKit browsers (Chrome, Edge, Safari). + +```html +
+``` + +```css +div { + width: 200px; + height: 100px; +} + +.no-scrollbars { + overflow: auto; + scrollbar-width: none; +} + +.no-scrollbars::-webkit-scrollbar { + display: none; +} +```