Reputation: 7716
I have implemented a subnav style Bootstrap scrollspy on my page but odd things seem to be happening. I have four sections, each in a div with I have given an id to. However, when either clicking on the link or scrolling, it is jumping to odd places.
It can be viewed here. http://www.writeupp.com/faq.aspx
Any ideas?
Upvotes: 3
Views: 3911
Reputation: 12561
Also note that when using scrollspy
in older versions of IE - if your anchor
s are pointing to html5 elements, e.g. section
, your .nav
will flicker between the first 2 anchors
in the ul
. This is because jquery can't figure out the position of these 'foreign' DOM elements. To fix this either use div
s instead of section
s or use modernizr.js
(specifically the html5shiv
component).
Check the Modernizr site for more info.
Upvotes: 0
Reputation: 998
I was having a similar issue that you speak of. Where the top nav flickers when I scrolled. I realized that it was because I had tabbable content on the page. My fix to this was to add data-target=".navbar" to my body element in addition to the data-spy="scroll" so that scrollspy knows which navigation bar to alter. I hope this helps.
<body data-spy="scroll" data-target=".navbar">
Upvotes: 3