diff --git a/index.html b/index.html index b6f6d0214..c64d578b8 100644 --- a/index.html +++ b/index.html @@ -31,6 +31,7 @@ Overflow scroll gradient Popout menu Pretty text underline + Scrollbars styling Shape separator System font stack Triangle @@ -918,6 +919,76 @@ var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop +
+

Scrollbars styling

+

Customise scrollbars style for the document and elements with overflow scrollable, on webkit platforms.

+

HTML

<div class="custom-scroll">
+  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit?</p>
+</div>
+
+

CSS

::-webkit-scrollbar {
+  width: 8px;
+}
+::-webkit-scrollbar-track {
+  box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
+  border-radius: 10px;
+}
+::-webkit-scrollbar-thumb {
+  border-radius: 10px;
+  box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
+}
+
+

Demo

+
+
+

+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit? +

+

+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit? +

+
+
+ +

Explanation

+
    +
  1. ::-webkit-scrollbar target the whole scrollbar element.
  2. +
  3. ::-webkit-scrollbar-track target only the scrollbar track.
  4. +
  5. ::-webkit-scrollbar-thumb Allow you to target and style the scrollbar thumb.
  6. +
+

There are many other pseudo elements that you can use to style scrollbars. More info about this on the + WebKit Blog +

+

Browser support

+
+
+ 87.3% +
+
+

⚠️ Currently scrollbar styling doesn't appear to be on any standards track. +

+ +

Shape separator

Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.

diff --git a/snippets/scrollbars-styling.md b/snippets/scrollbars-styling.md new file mode 100644 index 000000000..f4da38705 --- /dev/null +++ b/snippets/scrollbars-styling.md @@ -0,0 +1,78 @@ +### Scrollbars styling + +Customise scrollbars style for the document and elements with overflow scrollable, on webkit platforms. + +#### HTML + +```html +
+

Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit?

+
+``` + +#### CSS + +```css +::-webkit-scrollbar { + width: 8px; +} + +::-webkit-scrollbar-track { + box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + border-radius: 10px; +} + +::-webkit-scrollbar-thumb { + border-radius: 10px; + box-shadow: inset 0 0 6px rgba(0,0,0,0.5); +} +``` + +#### Demo + +
+
+

+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit? +

+

+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit? +

+
+
+ + + +#### Explanation + +1. `::-webkit-scrollbar` target the whole scrollbar element. +2. `::-webkit-scrollbar-track` target only the scrollbar track. +3. `::-webkit-scrollbar-thumb` Allow you to target and style the scrollbar thumb. + +There are many other pseudo elements that you can use to style scrollbars. More info about this on the [WebKit Blog](https://webkit.org/blog/363/styling-scrollbars/) + +#### Browser support + +⚠️ Currently scrollbar styling doesn't appear to be on any standards track. + + +* https://caniuse.com/#feat=css-scrollbar