How can I subtract from the navbar_height for example 2rem in the following function?
JavaScript
x
3
1
navbar_height = document.querySelector(".navbar").offsetHeight;
2
document.body.style.paddingTop = navbar_height + "px";
3
Thanks!
Advertisement
Answer
You can use calc
JavaScript
1
3
1
navbar_height = document.querySelector(".navbar").offsetHeight;
2
document.body.style.paddingTop = `calc(${navbar_height}px - 2rem)`;
3