Twitter Bootstrap Scrollspy not working at all

前端 未结 3 1888
暖寄归人
暖寄归人 2020-12-31 09:51

I have asked a previous question regarding Bootstrap ScrollSpy and this is my final attempt at trying to get this to work.

What I am trying to achieve is to change t

3条回答
  •  长发绾君心
    2020-12-31 10:29

    You need to move the data-spy and data-target attributes from the body:

    
    

    and move them to the div "spyOnThis":

    Should be:

    Per the documentation:

    "To easily add scrollspy behavior to your topbar navigation, just add data-spy="scroll" to the element you want to spy on (most typically this would be the body) and data-target=".navbar" to select which nav to use. You'll want to use scrollspy with a .nav component."

    Based on your HTML you also need to fix a couple things:

    Your list tags are not closed:

    
    

    Should be:

    
    

    Your divs not properly closed either:

    Available on 9th Jan 2013

    Available on 11th Jan 2013

    Available on 18th Jan 2013

    Available on 23rd Jan 2013

    Available on 25th Jan 2013

    Should be (just showing a couple of them):

    Available on 23rd Jan 2013

    Available on 25th Jan 2013

    Also it seems that the 100% height causes it to only highlight the bottom-most entry in the navbar list.

提交回复
热议问题