diff --git a/static/scripts/site.js b/static/scripts/site.js index 950c411..5ba8b4a 100644 --- a/static/scripts/site.js +++ b/static/scripts/site.js @@ -9,10 +9,17 @@ window.addEventListener("DOMContentLoaded", () => { } siteHeader.classList.add("visible"); + siteHeader.addEventListener("animationend", () => { + console.log("Animation ended"); + siteHeader.classList.add("sticky"); + }, false); + try { const documentReferrer = new URL(document.referrer); if (documentReferrer.pathname === "/") { siteHeader.classList.add("animated"); + } else { + siteHeader.classList.add("sticky"); } } catch { } }); diff --git a/static/styles/root.css b/static/styles/root.css index f44b87a..67fb2eb 100644 --- a/static/styles/root.css +++ b/static/styles/root.css @@ -240,6 +240,11 @@ h1, h2, h3, h4, h5, h6 { line-height: var(--body-header-line-height); } +h1:first-child, h2:first-child, h3:first-child, +h4:first-child, h5:first-child, h6:first-child { + margin-block-start: 0; +} + h1.site { color: rgb(var(--mid-blue)); font-size: 2.5em; @@ -265,15 +270,14 @@ h1.site a:hover { text-decoration: none; } header.site { display: flex; left: 0; - position: sticky; - top: 0.5rem; + position: fixed; + top: 0; visibility: hidden; width: 100%; z-index: 10000; } -header.site.visible { - visibility: visible; -} +header.site.visible { visibility: visible; } +header.site.sticky { position: sticky; } header.site.animated { animation: site-header-slide-in var(--transition-duration) ease-out; } @@ -282,7 +286,7 @@ header.site.animated { top: -200px; } to { - top: 0.5rem; + top: 0; } } @@ -348,8 +352,7 @@ img.circular { main { max-width: var(--content-width); - margin: 0 auto; - margin-block-start: var(--body-item-spacing); + margin: var(--body-item-spacing) auto; width: 100%; }