I have a simple navbar that is placed under a header. When the use has scrolled past the header I want the navbar to become fixed.
The problem is that when the user has reached the offset, the navbar becomes fixed, but the pages seems to be scrolled for the height of the navbar + the 20px bottom-margin it is applied.
The example looks pretty much like what I'm working on except that the header is not a title like this but a responsive carousel instead.
Since it is responsive I used Javascrip to launch the affix effect.
$('#nav').affix({
offset : {
top : function() {
return $('#header').height();
}
}
});
What I understand is that when the browser has scrolled past the height of the header (500 in my example) the #nav element will be applied the affix class. But why does it jump down like that?