From the course: Bootstrap 4 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use scrollspy

Use scrollspy - Bootstrap Tutorial

From the course: Bootstrap 4 Essential Training

Start my 1-month free trial

Use scrollspy

- [Instructor] Scrollspy is a really cool component that allows you to keep track of the scroll of the page and modifies classes according to the position of your elements. So the way that you use it is by creating a data attribute called scroll, and you do that on the container of the element that you want to track the scrolling in. Now that element also needs to have a position of relative, and you also need to target that element with a data target attribute, and then an ID, so we'll be doing this in just a second, so this will all make sense. Data target is usually how we put together what we are doing with the object that we're targeting. So in the case of navigation, I'm going to modify my navigation so that it's fixed to the top of the screen. That's going to cause some issues with the positioning, so I'll show you how to fix that. And then you can use a data offset attribute when you have those issues of positioning. So all this is going to make fantastic sense in just a…

Contents