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
- How to set the offset property for ScrollSpy in Bootstrap ?
- Include Bootstrap in AngularJS using ng-bootstrap
- Difference between bootstrap.css and bootstrap-theme.css
- Difference Between Bootstrap 3 and Bootstrap 4
- Difference between Bootstrap 4 and Bootstrap 5
- Beginning BootStrap (Part-1) | Introduction and Installation
- Beginning BootStrap (Part-2) | Grid System
- Bootstrap (Part-3) | Buttons, Glyphicons, Tables
- Bootstrap (Part-5) | DropDowns and Responsive Tabs
- Bootstrap (Part-4) | Vertical Forms, Horizontal Forms, Inline Forms
- How to get circular buttons in bootstrap 4 ?
- Bootstrap (Part-6) | Progress Bar and Jumbotron
- Bootstrap (Part-7) | Alerts , Wells, Pagination and Pager
- Bootstrap (Part-8) | Badges, Labels, Page Headers
- Bootstrap (Part-9) | Tooltips
- Bootstrap | Navigation Bar
- Bootstrap | Carousel
- Bootstrap | Cards
- Bootstrap | Badges and Breadcrumbs
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.