bootstrap 4 navbar fixed positioning

Bootstrap 4 – changes fixed-top Navbar background color on scrolling

// navbar background color change on scroll

    $(window).scroll(function(){
        var scroll = $(window).scrollTop();
        if(scroll < 300){
            $('.fixed-top').css('background', 'transparent');
        } else{
            $('.fixed-top').css('background', 'rgba(23, 162, 184, 0.9)');
        }
    });

 

6 thoughts on “Bootstrap 4 – changes fixed-top Navbar background color on scrolling”

  1. Your solution is not complete. If i scroll the page down and i refresh the page, the navbar will appear only after i scroll the page, and not after refresh.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top