if youre using bootstrap and want a smooth scrolling navbar that sticks to top when scrolled past, check this out. its super simple but often overlooked!
$(window).on("scroll", function() {if ($(this).scrollTop()) { //check scroll position$(".navbar").addClass('sticky');} else{$('.nav').removeClass('.stickey');}});just add a sticky class to ur navbar and style it w/ css for the fixed state. this snippet ensures nav stays on top but doesnt mess up other elements' positions.
> note: make sure you have jQuery included in project or use vanilla js equivalent