Fading bootstrap navbar on scrolldown, while changing text color

前端 未结 3 930
闹比i
闹比i 2021-02-11 08:18

so I\'m working on a Ruby on Rails app with a design given to me which calls for the navigation bar to be transparent at the top of the page, and then fade into solid white afte

3条回答
  •  情书的邮戳
    2021-02-11 08:55

    Something like this might help:

    window.addEventListener("scroll", function() {
        if (window.scrollY > 500) {
            $('.navbar').fadeOut();
        }
        else {
            $('.navbar').fadeIn();
        }
    },false);
    

    Change 500 with however many pixels from the top the place is that you want to do the fadeOut at.

提交回复
热议问题