如何使用CSS增加滚动条的宽度? [英] How can I increase a scrollbar's width using CSS?
问题描述
是否可以增加放置在<body>
内的<div>
元素上的滚动条的宽度?
Is it possible to increase the width of a scrollbar on a <div>
element placed inside the <body>
?
我不是在谈论浏览器本身上的默认滚动条,该页面以全屏模式运行,并且由于浏览器的滚动条从不显示图片,因此内部的<div>
元素具有自己的滚动条
I am not talking about the default scrollbar on the browser itself, this page runs in full screen mode and because the browser scrollbar never comes into picture, the inner <div>
element has its own scrollbar.
推荐答案
如果您谈论的是自动显示在div
和overflow: scroll
(或auto
)上的滚动条,则不会,这仍然是本机浏览器使用普通的OS小部件而不是可以设置样式(*)的滚动条.
If you are talking about the scrollbar that automatically appears on a div
with overflow: scroll
(or auto
), then no, that's still a native scrollbar rendered by the browser using normal OS widgets, and not something that can be styled(*).
尽管您可以按照Matt的建议将其替换为由可样式化div和JavaScript组成的代理,但在一般情况下,我不建议您使用它.脚本驱动的滚动条的行为永远不会与真正的OS滚动条完全相同,从而导致可用性和可访问性问题.
Whilst you can replace it with a proxy made out of stylable divs and JavaScript as suggested by Matt, I wouldn't recommend it for the general case. Script-driven scrollbars never quite behave exactly the same as real OS scrollbars, causing usability and accessibility problems.
(*:除了IE着色样式外,我也不推荐使用.除了仅使用IE之外,使用它们会迫使IE从当前Windows主题使用的漂亮滚动条图像退回到丑陋的Win95.样式的滚动条.)
(*: Except for the IE colouring styles, which I wouldn't really recommend either. Apart from being IE-only, using them forces IE to fall back from using nice scrollbar images from the current Windows theme to ugly old Win95-style scrollbars.)
这篇关于如何使用CSS增加滚动条的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!