From the course: Bootstrap 4 Layouts: Responsive Single-Page Design

Unlock the full course today

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

Scrolling to a location

Scrolling to a location - Bootstrap Tutorial

From the course: Bootstrap 4 Layouts: Responsive Single-Page Design

Start my 1-month free trial

Scrolling to a location

- [Instructor] In the last video, I mentioned that there was a slight problem when we click on these links and that is that it's not taking us to the top of each of these and I wanna show you how to add a little bit of a better animation so that it scrolls to a position on the page when you click on one of these links. So, to do that, I'm going to just copy and paste some code. This is a piece of code that I use really often and it allows you to smooth scroll an animation and I'll talk about the code a little bit. Let's go ahead and copy it from this URL and then I'm gonna paste it, let's go ahead and put it here at the top. Now in addition to that, I need to create a variable called topoffset and set to whatever I want that offset to be from the top of the screen, so I'm gonna say topoffset and I'll set that to the same thing I set at the beginning of the index.html in the body section, so I set that data-offset to 55, and that's what I'll do here. Let's go ahead and make this…

Contents