Fixed navigation bar header that also considers its height

Viewed 28

I made a fixed navigation bar header that when I press the buttons it goes to certain point of my page, but it doesn't considers its own height I mean: enter image description here enter image description here

enter image description here

I searched, but didn't found the answer, I even tried manually move it in a desesperation attempt:

let buttons = document.querySelectorAll('.navigation a');

let func = () => {
    setTimeout(() => {
        window.scrollY = window.scrollY + header.offsetHeight
    }, 1000);
}

buttons.forEach((element) => {
    element.addEventListener("click", func)
});

but didn't work either, how can I do it?

0 Answers
Related