--- title: scrollbar-width slug: Web/CSS/scrollbar-width translation_of: Web/CSS/scrollbar-width ---
scrollbar-width
属性允许开发者设置滚动条出现时的厚度
{{EmbedInteractiveExample("pages/css/scrollbar-width.html")}}
{{cssinfo}}
/* Keyword values */ scrollbar-width: auto; scrollbar-width: thin; scrollbar-width: none; /* Global values */ scrollbar-width: inherit; scrollbar-width: initial; scrollbar-width: unset;
auto |
系统默认的滚动条宽度 |
thin |
系统提供的瘦滚动条宽度,或者比默认滚动条宽度更窄的宽度 |
none |
不显示滚动条,但是该元素依然可以滚动 |
注意:scrollbar-width的长度值有可能从规范中删除,scrollbar-width属性本身也是如此。 (Issue 1958)
Note: User Agents must apply any scrollbar-width
value set on the root element to the viewport.
.scroller { width: 300px; height: 100px; overflow-y: scroll; scrollbar-width: thin; }
<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>
{{EmbedLiveSample("Example")}}
Specification | Status | Comment |
---|---|---|
{{SpecName("CSS Scrollbars", "#scrollbar-width", "scrollbar-width")}} | {{Spec2("CSS Scrollbars")}} | Initial Definition |
{{Compat("css.properties.scrollbar-width")}}