It appears that the website is utilizing custom CSS instead of pre-built Bootstrap classes.
Upon inspecting the element, a class named bd-sidebar
can be observed within the main container's CSS rules containing the following code snippet:
@media (min-width: 768px)
.bd-sidebar {
position: -webkit-sticky;
position: sticky;
top: 4rem;
z-index: 1000;
height: calc(100vh - 4rem);
}
Breaking down the aforementioned code:
The first line signifies a media query targeting screen widths of 768px or higher.
The position:sticky
property is thoroughly explained in this resource: https://css-tricks.com/position-sticky-2/. The prior line includes a vendor-prefixed version for compatibility purposes.
top:4rem
shifts the element downward by 4 relative ems as described here: 'relative ems', ensuring clearance with the top navigation bar.
z-index:1000
ensures visibility priority above and below specific content on the page.
Now, for the ingenious part!
height: calc(100vh - 4 rem)
This calculation subtracts 4 relative ems (representing the height of the nav bar) from 100vh
. A viewport height (vh
) measures a percentage of the full viewport height. For instance, 10vh would equate to 10% of the current viewport height (as per https://css-tricks.com/fun-viewport-units/)