鼠标悬停时左右滚动 div 内容

发布于 2024-12-04 21:12:14 字数 531 浏览 0 评论 0原文

再会。

我需要跟随鼠标的脚本,并根据鼠标所在的一侧滚动内容。如果向左则向左,如果向右则向右。

当 href 行超过块宽度时,我需要它,就像这里 http://cloud.ignatynikulin.com/ 45121918090s3R15193i

如果宽度超过,那么当您将鼠标放在 正确的。

可以做到这一点的东西: http://codecanyon.net/item/jquery-mouse -slider/full_screen_preview/143061

我尝试了该脚本,但它的问题是它需要依赖于一些我不依赖的宽度 有。

有什么插件或想法建议吗?

谢谢你!

Good day.

I need script that will follow the mouse and will scroll content depending on what side mouse is. If left then left, if right then right.

I need it for cases when line of hrefs will exceed width of block, like here http://cloud.ignatynikulin.com/45121918090s3R15193i

If the width is exceed then you will be able to scroll it when you put your mouse to right.

Something that will do that: http://codecanyon.net/item/jquery-mouse-slider/full_screen_preview/143061

I tried that script, but the problem with it is that it needs to rely on some width that I don't have.

Any plugin or ideas suggestion?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断念 2024-12-11 21:12:15

使包含的 div 定位为绝对。然后在 jQuery 中,捕获 onMouseMove 事件,计算鼠标相对于包含的 div 的位置(使用 .width() 这甚至可以使用动态宽度),并根据此更改包含的 div 的 left/right 属性。

参考: jQuery 获取元素内的鼠标位置

Make the containing div positioned absolute. Then in jQuery, catch the onMouseMove event, calculate the mouse position relative to the containing div (using .width() this works even with dynamic width), and change the left/right property of your containing div according to this.

Reference: jQuery get mouse position within an element

季末如歌 2024-12-11 21:12:14

查看 StackOverflow 的答案 - 这是一个完美的解决方案:

悬停时连续滚动[性能]

Check out the answer here from StackOverflow - it's a perfect solution:

Continuous scroll on hover [performance]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文