Verified Commit 5401f47f authored by Jakob Moser's avatar Jakob Moser
Browse files

Consider fixed header when scrolling to anchor in headlines (closes #13)

parent 23ec6715
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * Author: personads :: Maximilian Müller-Eberstein (ursprüngliche Version und Design); Jakob Moser
 * Author URI: https://personads.me/
 *
 * Version: 2.14.1
 * Version: 2.15.0
 * Requires PHP: 8.0
 *
 * License: GNU General Public License v3.0
@@ -102,6 +102,12 @@ body > header {
    background-color: var(--background-color);
}

h1, h2, h3, h4, h5, h6 {
    /* See: https://css-tricks.com/fixed-headers-and-jump-links-the-solution-is-scroll-margin-top/
       This way, the fixed header is considered when determining scroll position. */
    scroll-margin-top: calc(0.5em + 89px);  /* safety margin + height of header */
}

/* @@@ The following lines of code are adapted from https://stackoverflow.com/a/52226523/ (license details above). @@@
 *
 * We modified the CSS selector for the header and included another CSS rule in case the
@@ -331,6 +337,11 @@ header nav li:hover > ul {
    header nav:target {
        display: block;
    }

    h1, h2, h3, h4, h5, h6 {
        /* Header is now not fixed anymore, so we don't need to fix scroll margin behavior */
        scroll-margin-top: unset;
    }
}

/* ==== General styles: Articles ==== */