这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

CSS Scrollbars standardizes the obsolete scrollbar color properties introduced in 2000 by Windows IE 5.5.

基本范例

In this example we have chosen to use a thin scrollbar, with a green track and purple thumb.

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

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 特性

规范

规范 状态 注释
CSS Scrollbars Level 1 工作草案 初始定义。

可访问性关注

When you customize scrollbars, consider they have enough contrast and that their hit area is large enough for people who use touch input.

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

scrollbar-width

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
scrollbar-width Chrome 不支持 No Edge 不支持 No Firefox 完整支持 64
完整支持 64
完整支持 63 Disabled
Disabled ). To change preferences in Firefox, visit
IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 完整支持 64
完整支持 64
完整支持 63 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

用户必须明确启用此特征。

用户必须明确启用此特征。

scrollbar-color

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
scrollbar-color Chrome 不支持 No Edge 不支持 No Firefox 完整支持 64 注意事项
完整支持 64 注意事项
注意事项 On macOS, you need to set the General > Show scroll bars setting in System Preferences to "Always" for this property to have any effect.
完整支持 63 Disabled
Disabled ). To change preferences in Firefox, visit
IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 完整支持 64
完整支持 64
完整支持 63 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Scrollbars
  4. 特性
    1. scrollbar-color
    2. scrollbar-width

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1