如何使用 Jquery 滚动设置基于屏幕的 div 位置
我正在使用 Jquery 的 Scrollto 插件根据菜单上下滚动,但我希望菜单与滚动条保持一致。因此,如果我有一个 4000 像素高的页面,并且有人单击将其带到 2000 像素点的链接,菜单也会滑到那里。不确定这是 css 还是 jquery 问题。非常感谢任何帮助。
谢谢
I am using Jquery's Scrollto plugin to scroll up and down based on a menu but I would like the menu to stay with the scroller. So if I had a page that was 4000px high and someone clicks the link that takes them down to the 2000px point the menu would slide down there too. Not sure if this is a css or jquery issue. Any help is very appreciated.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在CSS中使用position:fixed。这是 jsfiddle 中的一个例子。
http://jsfiddle.net/E8Hyw/
You can use position:fixed in your css. Here is an example in jsfiddle.
http://jsfiddle.net/E8Hyw/
我很难想象你想要做什么,所以这可能会偏离很多:
你可以尝试将菜单放在滚动区域之外,并将其 div 浮动在正在滚动的部分上。不过,您的内容可能不是最适合的。
根据您想要做什么,这在语义上也可能更正确。菜单不是内容本身的一部分,而是内容的导航。
发布一部分 html/js 和/或模拟您想要做的事情的链接或图像会有所帮助。
I'm having a hard time picturing what you're trying to do, so this may be off by quite a bit:
You could try putting the menu outside of the scrolling area and floating its div over the portion that is scrolling. Your content might not be best suited to that though.
Depending on what you're trying to do, that might be a little more semantically correct as well. The menu isn't part of the content itself but is rather the navigation for the content.
Posting a partial chunk of html/js and/or a link or image that mocks up what you're trying to do would help a bit.