Scrollspy
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.
How it works
Scrollspy has a few requirements to function properly:- It must be used on a Bootstrap nav component or list group.
- Scrollspy requires
position: relative;
on the element you are spying on, usually the <body>
.
- Anchors (
<a>
) are required and must point to an element with that id
.
When successfully implemented, your nav or list group will update accordingly, moving the .active
class from one item to the next based on their associated targets.
- It must be used on a Bootstrap nav component or list group.
- Scrollspy requires
position: relative;
on the element you are spying on, usually the<body>
.
- Anchors (
<a>
) are required and must point to an element with thatid
.
.active
class from one item to the next based on their associated targets.Example in navbar
Scroll the area below the navbar and watch the active class change. The dropdown items will be highlighted as well.
Nested nav
Scrollspy also works with nested .nav
s. If a nested .nav
is .active
, its parents will also be .active
. Scroll the area next to the navbar and watch the active class change.
.nav
s. If a nested .nav
is .active
, its parents will also be .active
. Scroll the area next to the navbar and watch the active class change.list-group
Scrollspy also works with .list-group
s. Scroll the area next to the list group and watch the active class change.
.list-group
s. Scroll the area next to the list group and watch the active class change.Example:
Output:
First heading
To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the. Then add the data-bs-target attribute with the ID or class of the parent element of any Bootstrap .nav component.
Second heading
To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the. Then add the data-bs-target attribute with the ID or class of the parent element of any Bootstrap .nav component.
Third heading
To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the. Then add the data-bs-target attribute with the ID or class of the parent element of any Bootstrap .nav component.
Fourth heading
To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the. Then add the data-bs-target attribute with the ID or class of the parent element of any Bootstrap .nav component.
Fifth heading
To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the. Then add the data-bs-target attribute with the ID or class of the parent element of any Bootstrap .nav component.
Do you Know?
Progamming is what actually means ?What is software development ?
How we categorized software development in different manner.
C Plus Plus
Python
Java Development
Web Designing
Javascript
Mysql
Oracle