Affix在Bootstrap 4 alpha中不工作 [英] Affix is not working in Bootstrap 4 alpha
本文介绍了Affix在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不是添加类到navbar的是affix。任何人都可以告诉我如何解决这个问题? 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.
推荐答案
通过这个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('navbar');
}
});
这篇关于Affix在Bootstrap 4 alpha中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文