From the course: Bootstrap 5 Essential Training

Unlock this course with a free trial

Join today to access over 24,000 courses taught by industry experts.

Scrollspy

Scrollspy

- [Instructor] Scrollspy provides a way for a nav or a list group to keep track of how another element is scrolling. And it can be quite useful, I really do love scrollspy and the way that it works is sort of interesting because there's not like a lot of existing pieces that you have to add, you simply have a navigation. And to that navigation you want to add a data spy of scroll, and then you want to identify what item you want to keep track of. So in other words, there's two parts, the element that you want to spy and then the element that you want to modify. On the element that you want to spy, you add the data_bs_spy of scroll as well as the data_bs-spy ID with the ID of the element that you want to keep track of. There's also an option to control the offset, which can come in handy, especially when you want the trigger to happen not exactly when the object is at a certain position but maybe a little bit before or a little bit after and I think it'll make more sense when I show…

Contents