2

我的页面上有 70 多个 div。

在用户滚动页面之前,我不想一次显示所有 div。我试图在我的页面上隐藏溢出的元素,当用户滚动页面时,隐藏的 div 应该再次淡入。

但是如果窗口滚动,我无法隐藏溢出的元素,也找不到任何方法来再次淡入溢出的元素。

不过我试了一下——

$(function(){
   $(window).css("overflow","hidden");
    var lengthy= $('.content').length;
         alert(lengthy);  

        var scrollbottom= $(window).scrollTop()+$(window).height();

        $(window).scroll(function(){

             $(document).css("overflow","hidden");
            if($(window).height() >scrollbottom)
            {
                $(document).fadeIn();
            }
        });


});

提琴手

如何才能做到这一点?

4

1 回答 1

1

将你的 Jquery 编辑成这样的东西

$(window).scroll(function () { 
   if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
      //Add something at the end of the page
   }
});

这样做是在页面结束前达到 10px 时发生滚动,而不需要在页面的最后。没有必要拥有它,但它可以更好地控制页面应该在什么点滚动......

这个例子会告诉你我认为你想要什么 http://www.webresourcesdepot.com/dnspinger/

于 2013-07-29T12:27:33.240 回答