I\'m migrating to bootstrap 3.0.0 and I\'m having issues with an affixed menu to the left: as soon as it becomes affixed (after 10px scroll), its width changes. In this fiddle i
I used $('.affix-element').width($('.affix-element-parent').width()).affix()
Works well :)
Here is my HTML
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#committees-navbar">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand">Committees</span>
</div>
<div id="committees-navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav nav-stacked" data-spy="affix" data-offset-top="250">
<li class="col-xs-12"><a ng-click="scrollTo('boardCommittee')">BOARD OF DIRECTORS</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('madrasaCommittee')">MADRASATUL JAMALIYAH</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('shababCommittee')">SHABAB</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('bwaCommittee')">BURHANI WOMEN</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('tncCommittee')">TAISEER UN NIKAH</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('fmbCommittee')">FAIZUL MAWAIDUL BURHANIYAH</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('websiteCommittee')">WEBSITE</a></li>
<li class="col-xs-12"><a ng-click="scrollTo('tadfeenCommittee')">TADFEEN</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
And this is my JS fix
$(function () {
var resize = function () {
var sidebarNav = $(".sidebar-nav");
var sidebarNavAffix = $(".sidebar-nav .affix");
if (sidebarNavAffix.length && (sidebarNavAffix.width() !== sidebarNav.width())) {
sidebarNavAffix.width(sidebarNav.width());
}
}
$(window).on({"scroll" : resize, "resize" : resize});
});
I had the same problem and fixed with this:
$(window).resize(function () {
$('#category-nav.affix').width($('#content').width());
});
basically in an event of resize I calculate the content div's width and set the width of affixed element to that.