Affix is not working in Bootstrap 4 (alpha)

前端 未结 10 537
暖寄归人
暖寄归人 2020-12-02 21:30

According to Bootstrap 3 docs I have added following attributes to a navbar:

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 22:09

    simple use class fixed-top in bootstrap 4 and use addClass and removeClass

    $(window).on('scroll', function(event) {
        var scrollValue = $(window).scrollTop();
        if ( scrollValue > 70) {
             $('.navbar-sticky').addClass('fixed-top');
        }else{
           $('.navbar-sticky').removeClass('fixed-top');
        }
    });
    

提交回复
热议问题