I use the following code to use smooth scroll when clicking a link with anchor. This works perfect but I need to add some offset top of 88 pixels, because of a static header.
How can I extend this code and add a off set top of 88px?
Code:
<script type="text/javascript" >
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
</script>