如何在滚动条上移动元素
我想以不同的速度垂直移动一些元素(带有图像的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅: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 :)