How to use Bootstrap scroll spy?

前端 未结 8 572
眼角桃花
眼角桃花 2020-12-08 02:52

I cannot quite get the scroll spy to work properly with a vertical nav. Below you can find the code I use. For some reason, only \"Two\" gets active.

Anyone has an i

8条回答
  •  萌比男神i
    2020-12-08 03:51

    In sorting this out for myself, I've found that the element being spied upon needs to have a scroll bar.

    Take a look at this Fiddle: http://jsfiddle.net/adamp/qgU6h/1/

    You can either spy directly on the body element ($('body').scrollspy()) or give your content an explicit height and force it to show a scrollbar.

    (If you look at the Bootstrap documentation example, it does the fixed-height trick.)

提交回复
热议问题