Scrollspy demo using a navigation bar
body
Attributes
data-spy="scroll"
data-target="#scrollspy-demo"
data-offset="56"
(⇒ Note 1 )nav.navbar.fixed-top.navbar-light
Attributes
id="scrollspy-demo"
style="background: rgba(222,222,222,0.6);"
(⇒ Note 2 )Scrollspy demo (1)
(see Navbar - brand )ul.nav.nav-pills
(see Navbar - nav )
div.container
Attribute
id="{position-id}"
to the tracking targete elementsdata-offset="56"
is the height of the navigation bar (px). As this page uses a fixed-top bar, scroll caluculation should be adjusted to set the origin of scroll tracking to just beneath the bar.iframe
). This demo uses a translucent navigation bar as compromise.Below are dummy scrolling contents. Each heading have a specific id="{position-id}"
for scroll tracking.