Reputation:
I'm using Bootstrap affix to fix my navbar at the top once it's been reached by scrolling down. I added the affix properties in the div, but it's still not working. I have both bootstrap.min.css and bootstrap.min.js imported. Anything else I have missed?
<div id="nav-wrapper"><!--nav-wrapper-->
<div class="container"><!--container-->
<div class="row" id="navigation"><!--header-->
<div class="col-md-12" data-spy="affix" data-offset-top="60" data-offset-bottom="200"><!--col-md-12-->
<div class="nav"><!--nav-->
<div class="menu-main-menu-container">
<ul>
<li></li>
<li></li>
<li></li>
</ul></div>
</div><!--nav-->
</div><!--col-md-12-->
<div class="clearfix"></div>
</div><!--header-->
</div><!--container-->
</div>
Upvotes: 3
Views: 9272
Reputation:
I found this works:
JS:
$(function() {
$('#nav-wrapper').height($("#nav").height());
$('#nav').affix({
offset: { top: $('#nav').offset().top }
});
});
CSS:
#nav.affix {
position: fixed;
top: 0;
width: 100%
}
#nav > .navbar-inner {
border-left: 0;
border-right: 0;
border-radius: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
-o-border-radius: 0;
}
Upvotes: 1