How to shrink navigation menu when scrolling down?

后端 未结 3 1941
情话喂你
情话喂你 2020-12-28 10:36

For a new site I am developing I would love to shrink the navigation menu when the user scrolls down.

Something similar to what you can see at the IBM site: http://w

3条回答
  •  温柔的废话
    2020-12-28 10:55

    What you do is check the scroll value of the window. If it is greater than zero then the user has scrolled down. If so then hide the banner (or shrink or whatever). If they go back to the top then reshow it.

    http://jsfiddle.net/rxXkE/

    $(window).scroll(function () { 
    console.log($(window).scrollTop());
    if ($(window).scrollTop() > 0) {
        $(".banner").slideUp();
    }
    else {
         $(".banner").slideDown();   
    }
    

    });

提交回复
热议问题