向下滚动时 DIV 向上移动 [英] DIV move up when scrolling down

查看:66
本文介绍了向下滚动时 DIV 向上移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用浏览器上的滚动条向下移动时,我一直试图让 DIV 向上移动,但我找不到有效的解决方案.

I've been trying to get a DIV to move up when using the scroll on browser to move down, but I can't find a solution which works.

更具体地说,例如,如果我用图像填充 DIV,当我向下滚动浏览器窗口滚动条时,我希望这些图像向上滚动.因此,当您在页面向下移动的时间越长时,DIV 就会向上移动并显示更多图像.

More specifically, for example if I fill a DIV with images, I want these images to scroll upwards when I scroll the browser window scrollbar downwards. So as you move longer down the page, the DIV moves upwards and shows more images.

你能给我一些如何获得这种效果的建议吗?

Could you give me some suggestions how to receive such an effect?

推荐答案

试试这个:

$(window).scroll(function(){            
    $("#scrollingDiv").stop().animate({ "marginTop": ($(window).scrollTop() + 30) + "px"}, "slow"); 
});

这篇关于向下滚动时 DIV 向上移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆