简体   繁体   English

样式浏览器滚动条

[英]Styling Browser Scrollbar

I saw this years before, but since it was not widely supported, websites are dropping usage of it. 我在几年前看到过,但由于它没有被广泛支持,网站正在放弃使用它。

I am currently designing a website which will have scrollbars inside the design and wondering whether CSS2 have any specification on styling browser scrollbars because the default colours don't fit. 我目前正在设计一个网站,它将在设计中包含滚动条,并想知道CSS2是否有关于样式浏览器滚动条的任何规范,因为默认颜色不适合。 If there's no specification, any reference to specific browser behaviour would be appreciated. 如果没有规范,任何对特定浏览器行为的引用都将受到赞赏。

If there's no CSS specification on it, I would have to rely on a custom generated scrollbar using JS. 如果没有CSS规范,我将不得不依赖于使用JS自定义生成的滚动条。 References on how to build one is also appreciated. 关于如何建立一个的参考也值得赞赏。

I quote myself from this thread , since it's related: 我从这个帖子中引用自己,因为它是相关的:

From a usability point of view, changing scroll bars is a no-go. 从可用性的角度来看,改变滚动条是不可取的。 The user is familiar with his/her operating system and the visual environment it provides. 用户熟悉他/她的操作系统及其提供的可视环境。 Changing this does create confusion, especially among those who are new to using computers, old people etc. 改变这种情况确实会造成混乱,尤其是那些刚接触电脑,老人等的人。

The majority of users today will probably recognize a scroll bar as long as it has it's basic shape - and many will not even use the bar itself, but just the scroll wheel on the mouse. 今天的大多数用户可能会识别滚动条,只要它具有基本形状 - 许多用户甚至不会使用条形本身,而只是鼠标上的滚轮。

It's still a thing to think about though. 尽管如此,还是要考虑一下。 Consider your audience. 考虑您的受众。 And whatever you do make sure it actually works on all platforms/in all browsers if you use a custom scroll bar. 无论你做什么,如果你使用自定义滚动条,确保它实际上适用于所有平台/所有浏览器。

A JavaScript solution can be found at 可以在以下位置找到JavaScript解决方案 http://www.hesido.com/web.php?page=customscrollbar . http://www.hesido.com/web.php?page=customscrollbar Note that you do have to pay for this, but even if you don't want to go that route it shows what is possible. 请注意,您必须为此付费,但即使您不想走这条路线,它也会显示可能性。

Otherwise a jQuery solution and a Prototype solution are also available. 否则,还可以使用jQuery解决方案Prototype解决方案

WebKit支持另一种机制

You can do it like this: 你可以这样做:

<style>
body {
    scrollbar-face-color: #000000;
    scrollbar-highlight-color: #000000;
    scrollbar-shadow-color: #000000;
    scrollbar-3dlight-color: #000000;
    scrollbar-arrow-color: #000000;
    scrollbar-track-color: #000000;
    scrollbar-darkshadow-color: #000000;
}
</style>

but it only works in Internet Explorer and Opera (thanks, Julien!). 但它只适用于Internet Explorer和Opera(谢谢Julien!)。 And you might want to use different colours. 你可能想要使用不同的颜色。 8-) 8-)

I haven't gotten around to trying these solutions, but they do look very promising and are claimed to degrade nicely. 我还没有尝试过这些解决方案,但它们确实看起来非常有前途,并声称它们会很好地降级。

This would be my first choice 这将是我的第一选择
http://www.hesido.com/web.php?page=customscrollbar http://www.hesido.com/web.php?page=customscrollbar

http://www.n-son.com/scripts/jsScrolling/new/example5.html http://www.n-son.com/scripts/jsScrolling/new/example5.html

many browsers support some sort of styling the scrollbars, but nothing of it is standardised in css. 许多浏览器支持滚动条的某种样式,但它没有在css中标准化。

also, as arve systad said, changing such basic widgets of the OS is a no-go—though one should be careful with changing buttons then too 另外,正如arve systad所说,改变操作系统的这些基本小部件是不可取的 - 但是也应该小心改变按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM