xref: /plugin/combo/resources/snippet/js/menubar-fixed-top.js (revision 85e82846b0a214bc35e62864fa49d9cad0723d0e)
1window.addEventListener("DOMContentLoaded",function(){
2    let fixedNavbar = document.querySelector(".navbar.fixed-top")
3    // correct body padding
4    let offsetHeight = fixedNavbar.offsetHeight;
5    document.body.style.setProperty("padding-top",offsetHeight+"px");
6    // correct direct navigation via fragment to heading
7    let style = document.createElement("style");
8    style.classList.add("menubar-fixed-top")
9    style.innerText = `main > h1, main > h2, main > h3, main > h4, main > h5, #dokuwiki__top {
10    padding-top: ${offsetHeight}px;
11    margin-top: -${offsetHeight}px;
12    z-index: -1;
13}`;
14    document.head.appendChild(style);
15});
16