How to Build a Sticky Navigation Bar on Scroll Using JavaScript DOM

Make your navbar stick to the top of the page as you scroll — using pure JavaScript and CSS.