如何在滚动条上移动元素

发布于 2024-12-13 14:16:45 字数 382 浏览 5 评论 0原文

我想以不同的速度垂直移动一些元素(带有图像的 div)。我已经通过带有锚点的 animate jquery 函数部分实现了这一点。但是我不知道如何使用滚动事件来做到这一点。我希望通过滚动也能进行相同的移动(以不同的速度垂直移动)。滚动必须对“浏览器滚动”和“鼠标滚动”具有相同的效果(不确定这些名称)。

function scroll() {
    $("#logo").animate({ "top": "+=180px" }, 1000);
$("#logo2").animate({ 'top': "+=450px"}, 1000);
}

这是我得到的功能。

我做了同样的研究,发现了一些案例,但没有一个真正对我有帮助。

任何帮助将不胜感激。

I want to move some elements (divs with images) vertically at different speed. I already achieve this partially with the animate jquery function with anchors. However I couldn't figure it out how to do it with the scroll event. I want the same movement (vertically at different speed) also through the scrolling. The scrolling must have the same effect on the "browser-scroll" and on the "mouse-scroll" (no sure about these names).

function scroll() {
    $("#logo").animate({ "top": "+=180px" }, 1000);
$("#logo2").animate({ 'top': "+=450px"}, 1000);
}

this is the function that I got.

I made same research and I found some cases but none of them helped me really.

Any help would be much appreciated.

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

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

发布评论

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

评论(1

北音执念 2024-12-20 14:16:45

请参阅:http://jsfiddle.net/5HHxK/1/

你想要什么?如果您想要不同的速度,具有相同的“位置”,只需减慢速度:)

See: http://jsfiddle.net/5HHxK/1/

What is it you want? If you want different speeds, with same "position", just slow the speed :)

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