I recently put together documentation using the CSS and JavaScript from Bootstrap docs. Here is a snippet of the sidebar code in my documentation:
<div class="col-md-3 docs">
<div class="bs-docs-sidebar">
<ul class="nav docs-sidebar-nav">
<li class="active">
<a href="#one">One</a>
</li>
<li>
<a href="#two">Two</a>
</li>
</ul>
</div>
</div>
Additionally, here is the jQuery code for .affix
:
$(document).ready(function () {
$('.bs-docs-sidebar').affix({ offset: { top: 290 } })
})
However, upon opening the page, I noticed that the sidebar does not display entries "One" and "Two" correctly. As I scroll down, the sidebar only shows "Two" as active but never displays entry "One."
I am currently using Bootstrap v3.2.0. Can someone explain why the sidebar is not functioning properly with .affix
? I even attempted to use data-spy=affix
, but that didn't solve the issue.
Does anyone know how to fix this problem and make the sidebar work seamlessly with affix?