CSS スクロールバー

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

CSS スクロールバー (CSS Scrollbars) は、 2000 年に Windows の IE 5.5 で導入され、廃止されたスクロールバーの色のプロパティを標準化するためのものです。

基本的な例

この例では、緑色のトラックと紫色のつまみを持った細いスクロールバーを使用してみました。

css
.scroller {
  width: 300px;
  height: 100px;
  overflow-y: scroll;
  scrollbar-color: rebeccapurple green;
  scrollbar-width: thin;
}

HTML

html
<div class="scroller">
  Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion
  daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens
  corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts
  fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber
  earthnut pea peanut soko zucchini.
</div>

結果

リファレンス

CSS プロパティ

仕様書

Specification
CSS Scrollbars Styling Module Level 1

アクセシビリティの考慮

スクロールバーをカスタマイズする場合は、十分なコントラストがあることと、ヒット領域がタッチ入力を使っている人が操作できるだけ大きいかどうかを考慮してください。

ブラウザーの互換性

scrollbar-width

css.properties.scrollbar-color

BCD tables only load in the browser

css.properties.scrollbar-width

BCD tables only load in the browser

scrollbar-color

css.properties.scrollbar-color

BCD tables only load in the browser

css.properties.scrollbar-width

BCD tables only load in the browser

関連情報