
Specifies element to apply Scrollspy plugin. position will use the HTMLElement.offsetTop and HTMLElement.offsetLeft properties to get scroll coordinates. offset will use the Element.getBoundingClientRect() method to get scroll coordinates. auto will choose the best method to get scroll coordinates. Pixels to offset from top when calculating position of scroll.įinds which section the spied element is in. For data attributes, append the option name to data-bs-, as in data-bs-offset="". Options can be passed via data attributes or JavaScript. getOrCreateInstance ( scrollSp圜ontentEl ) // Returns a Bootstrap scrollspy instance getElementById ( 'content' ) var scrollSpy = bootstrap. Then add the data-bs-target attribute with the ID or class of the parent element of any Bootstrap. To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the ). We keep adding some more example copy here to emphasize the scrolling and highlighting. It's repeated throughout the component example. Note that as you scroll down the page, the appropriate navigation link is highlighted. This is some placeholder content for the scrollspy page. Scroll the area next to the list group and watch the active class change. Navbar Item 1 Item 1-1 Item 1-2 Item 2 Item 3 Item 3-1 Item 3-2 Item 1.

Scroll the area next to the navbar and watch the active class change. Navbar First Second Dropdown Third Fourth Fifth First heading.


