So, I have this single page that consists of a few sections. Users can go to these sections by scrolling themselves or clicking in the navbar (a href with anchor). Due to th
I like to dynamically offset the height header (or navbar) like this:
$('.nav-link').click(function(e){ let divCoords = $(e.target.hash).offset(); let height = $('header').height(); e.preventDefault(); window.scrollTo({ left: divCoords.left, top: divCoords.top - height, behavior: 'smooth' }); });