Google 是如何制作滚动条的?
我刚刚访问 http://www.google.com/finance 并注意到页面中间有一个看起来很棒的滚动条。
Google 如何创建这种滚动条的外观/感觉?
注意:此滚动条与 Google 在其 Wave 产品中使用的滚动条不同。
更新:
滚动条不会立即出现。不要刷新页面。让页面保持理想状态一段时间,直到世界上出现新的新闻报道。一旦出现新的新闻报道,新文章就会导致滚动条出现。
I was just on http://www.google.com/finance and noticed on the middle of the page an awesome looking scrollbar.
How does Google create this scrollbar look/feel?
Note: this scrollbar is different than what Google used with it's Wave product.
UPDATE:
The scrollbar doesn't appear immediately. Do NOT refresh the page. Let the page sit ideal for a few moments until there is new news story in the world. Once a new news story appears, the new article will cause the scrollbar to appear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
非常有趣的问题。我只是有空闲时间,花了它来实现这个简单的例子(花了大约 1 小时喝一杯茶和糖果;))。看看这个:
它需要 JQuery 和 Jquery UI,示例仍然存在一些问题,但主要思想已经实现。示例仅在 Chrome 7 中测试。
你可以用它制作一个 jquery 插件。
Very interesting question. I just had spare time and spent it to implement simple example of this (spent about 1 hour with a cup of tea with candies ;)). Look at this:
It requires JQuery and Jquery UI, and the example still has some issues, but main idea is realized. Example tested ONLY in Chrome 7.
You can make a jquery plugin from it.
并不是说我可以看到它,但我想象一个由各种图像制成的自定义控件。
您制作一个轨道图像,平铺以构成背景,顶盖和底盖图像充当前进/后退按钮(具有悬停和按下状态),可移动控件通常由三部分组成,两侧有两个端盖一个可平铺的中心区域,可以调整大小以适应。然后,您监视控制区域上的拖动并将其保持在轨道内,然后单击(或更好的鼠标按下)前进/后退按钮。
如果您不想,有像 jQuery UI Slider 这样的库可以为您处理这个问题自己编码。
Not that I can see it, but I imagine a custom control made out of various images.
You make a track image that tiles to make up the background, top and bottom cap images to act as the forward/back buttons (with hover and depressed states) and the moveable control is usually three-part, two end-caps on either side of a tileable central area that can be resized to suit. Then you monitor drags on the control area and keep it bound within the track, and clicks (or better mousedown) on the forward/back buttons.
There are libraries like jQuery UI Slider that handle this for you if you do not wish to code it yourself.
尽管其他人已经指出了这是如何完成的(这就是问题,因此它们是“正确”的答案),但我想建议一个替代答案......
认真考虑为什么你想这样做
通过设置 2 个 css 属性(例如不需要任何代码)即可轻松添加滚动条。
定义滚动条的问题在于它的行为与本机滚动条的行为不太一样。
这些可能看起来不是一个主要问题,但更改/删除用户所操作的 UI 控件的“行为”通常不建议使用。
引用 Jakob Neilsen 可用性网站“Alertbox”文章:“滚动和滚动条< /a>" - 2005 年 7 月 11 日。(强调我的)
Although others have indicated how this is done (and that was the question, thus they are the "correct" answer) I'd like to suggest an alternative answer...
Seriously consider why you would want to do this
A scrollbar would be just as easy to add by setting 2 css properties (e.g. no code required)
The problem with the custom scrollbar is that it doesn't behave quite like a native one does.
These may not seem like a major issue, but changing/removing the "behavior" of UI controls that users are used to is generally not advised.
Quote from Jakob Neilsen's Usability site "Alertbox" article: "Scrolling and Scrollbars" - July 11, 2005. (emphasis mine)