Sometimes while designing the website, we include some attractive features which makes website eye-catching. One of the features is Bootstrap scrollspy which target the navigation bar contents automatically on scrolling the area.
Example 1 : Scrollspy Vertical Navigation bar
Example 2 : Scrollspy Horizontal Navigation bar
Some attributes are added with the elements for the implementation of this feature.
These are –
- data-spy It is an attribute that is to be added with the element which is using as the scrollable area (in the above example we are taken it as the body).
The value of data-spy is scroll.
- data-target This attribute is used to connect navigation bar with the scrollable area.
It takes the value as the name of the ID or class of the navigation bar.
- data-offset This attribute specifies the number of pixels to offset from top when calculating the position of scroll.
Note: A default value of “data-offset” is taken as 10 pixels. It is an optional attribute.
- Bootstrap 4 | Scrollspy
- Include Bootstrap in AngularJS using ng-bootstrap
- Bootstrap | Tables | Set-2
- Bootstrap | Tables | Set-1
- Bootstrap 4 | Images
- Bootstrap 4 | Alerts
- Bootstrap 4 | Cards
- Bootstrap 4 | Forms
- Bootstrap 4 | Carousel
- Bootstrap | Spinners Set-2
- Typography in Bootstrap
- Clearfix in Bootstrap
- Bootstrap | Spinners Set-1
- Bootstrap 4 | Badges
- Bootstrap 4 | Jumbotron
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.