2

I am having an issue with Bootstrap ScrollSpy in regards to the scrolling position of a selected element. The issue occurs at the bottom of the page, I have multiple relatively short sections of content through out the page. They are collapsed and expand onClick, (so yes, if I choose to have all open then there seem to be no problem) and when I reach the bottom of page before all have been selected by scrollspy it jumps to the last element on nav.

It seems to be a issue with no more scrollable area. (Also adding extra white space padding to kill design is not an option)

I have added scrollspy to body, my body has no height values added, offset has no effect other then starting the highlighted element was to early.

Here is a JSFiddle of my code: http://jsfiddle.net/Abuu/sAUee/

    $( document ).ready(function() {
    $('body').scrollspy({ 'target': '#nav', 'offset': 10 });
});

I have only found one similar question here on So, but it has not been answered: Bootstrap - Scrollspy scrolling skipping second to last section

Thanks in advance.

4

1 回答 1

2

当部分不足以占用显示空间时会发生这种情况,因此当页面上同时有几个部分时,ScrollSpy 默认为最后一个部分。据我所知,这只发生在页面的最后部分。

如果您为占用屏幕空间的每个部分添加一个高度,您会发现它可以正常工作。

于 2014-04-03T17:44:54.983 回答