I\'ve made a page with bootstrap 3.2.1 and use scrollspy in this page. In the first click on menu doesn\'t work offset height for scroll page, But after the second click works o
That because you set the navbar to fixed on scroll down (after y > 90). So you need to discount the height of the navbar when it's fixed.
You need a dynamic value, based on your code, a way to do this is using a function with the same parameters. The height of the navbar is 30px so you need to add it.
function offsetHeight() {
if ($(window).scrollTop() > 90) {
return 120;
}
else {
return 150;
}
};
JSFiddle