词缀在 Bootstrap 4 (alpha) 中不起作用 [英] Affix is not working in Bootstrap 4 (alpha)

查看:26
本文介绍了词缀在 Bootstrap 4 (alpha) 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Bootstrap 3 文档,我向导航栏添加了以下属性:

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

<nav class="navbar no-margin-bottom" data-spy="affix" data-offset-top="90" >
...
</nav>

向下滚动页面后,Bootstrap 4 没有向作为词缀的导航栏添加类.谁能告诉我如何解决这个问题?Bootstrap.js 和 jQuery.js 正在运行.

After scrolling down the page Bootstrap 4 is not adding class to navbar which is affix. Can anyone tell me how to solve this problem? Bootstrap.js and jQuery.js are working.

推荐答案

虽然在 Bootstrap 版本 4 中删除了词缀.但是,您可以通过此 jQuery 代码实现您的目标:

Although the affix is removed from Bootstrap in version 4. However, you can achieve your goal through this jQuery Code:

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

这篇关于词缀在 Bootstrap 4 (alpha) 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆