内部锚链接使用 Tiny Scrollbar 插件破坏滚动条
帮助!我正在尝试使用来自 www.baijs.nl 的优秀 Tiny Scrollbar 构建一个网页。但是,我需要添加一些内部锚链接以跳转到内容的适当部分,但这被证明是一个问题。 (所有内容,包括内部锚链接,都位于 Tiny Scrollbar div 容器内)。
请参阅我的基本模型 http://jsfiddle.net/uy4hK/
我的问题是,虽然内部链接是跳到正确的部分,右侧的滚动条没有更新到正确的位置 - 它只是停留在顶部。有一个可以使用的更新方法,并且该演示还有一个内部滚动版本,但使用数字变量(200px),但我无法调整它以使其在我的 jsfiddle 演示中工作。我实际上不能使用数字,因为内容可能会有所不同,并且内部链接位于微型滚动条容器内的内容内。
有人可以帮忙吗?
Help! I'm trying to build a webpage using the excellent Tiny Scrollbar from www.baijs.nl. However, i need to add some internal anchor links to jump down to the appropriate section of the content but this is proving to be a problem. (All the content, including the internal anchor links, are housed within the Tiny Scrollbar div containers).
See my basic mockup on http://jsfiddle.net/uy4hK/
My problem is that although the internal link is jumping down to the correct section, the scrollbar on the right is not updating to the correct position - it just stays at the top. There is an update method that can be used, and the demo also has a version of internal scrolling but using a number variable (200px) but i am unable to tweak this to make it work in my jsfiddle demo. I can't really use a number because content can vary and the internal links are within the content inside the Tiny Scrollbar container.
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
jsFiddle: http://jsfiddle.net/fausak/uy4hK/2/< /a>
我认为你可以使用 jQuery 的
position()
方法。试试这个:jsFiddle: http://jsfiddle.net/fausak/uy4hK/2/
I think you can pull this off with use of jQuery's
position()
method. Try this:谢谢弗萨克。
实际上,在这种情况下,我们希望将锚链接设置为滚动条外部。我们可以例如:
修改 rfausak 代码:
Thanks rfausak.
Actually in situation, we want to make anchor link external from scrollbar. We can make for example :
Modifying of rfausak code:
我不确定您所要求的问题是否可以通过 Tiny Scrollbar 插件实现。不过,以下内容将使您非常接近:
如果您的内容是静态的,您可以将
'bottom'
替换为实际像素长度,例如'25px'
。I'm not sure if exactly what you're asking is possible with the Tiny Scrollbar plugin. The following will get you pretty close, though:
If your content is static, you could replace
'bottom'
with an actual pixel length, like'25px'
.