无法使用 CSS 将宽度和高度应用于 -webkit-scrollbar
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-thumb {
background-color:#808080;
}
为什么宽度和高度属性不起作用?
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-thumb {
background-color:#808080;
}
Why do the width and height attributes not work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
width
用于垂直滚动条,height
影响水平滚动条。您无法定义垂直滚动条的高度。这取决于内容大小。如果您想将背景图像添加到滚动条,它们会像普通元素一样添加:
Fiddle
width
is for vertical scrollbars andheight
affects horizontal scrollbars. You can't define height for a vertical scrollbar. That is dependent on content size.If you want to add background images to your scrollbar, they are added like normal elements:
Fiddle
除了
height
示例: http:// /jsfiddle.net/jasongennaro/gBrNf/
相当肯定,这是因为浏览器根据内容的高度确定滚动条的高度。 (更多的内容等于更短的滚动条......这是一个视觉提示,我不确定你可以覆盖。)
This works, except for the
height
Example: http://jsfiddle.net/jasongennaro/gBrNf/
Fairly certain that's because the browser determines the height of the scrollbar based on the height of the content. (More content equals shorter scrollbar... it's a visual cue I am not sure you can override.)
您无法将高度应用于滚动条,因为浏览器需要根据页面上滚动的距离(取决于页面的高度)来调整高度。
您可以通过在单个页面上放置适合的内容以及高度为 3000 像素的内容来测试它,并查看滚动条将如何降低其尺寸。
You cannot apply height to scrollbars as the browser needs to adjust height based on how much there is to scroll on the page (depending on the height of the page).
You can test it by having content that fits on a single page and by having content that is 3000px in height and see how the scrollbar will lower its size.