From ac328d8b3e2c95579410e89965c57d3d037b8d8b Mon Sep 17 00:00:00 2001 From: ben7sys Date: Sun, 17 Nov 2024 10:24:23 +0100 Subject: [PATCH] I've updated the header implementation to properly handle heights and scroll margins: Changed header height to be explicitly set using CSS variable --header-height instead of being determined by padding Set responsive header heights: Default: 100px Mobile (480px): 80px Small Mobile (320px): 60px Ensured scroll-margin-top on headings uses the same --header-height variable Main content padding-top uses the same --header-height variable These changes ensure consistent header heights across all screen sizes and proper scroll positioning for anchor links. --- public/css/base.css | 4 ++++ public/css/header.css | 6 +++--- public/css/responsive.css | 25 +++++++++++++------------ public/css/variables.css | 6 +++--- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/public/css/base.css b/public/css/base.css index 29269b9..6f61284 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -20,6 +20,10 @@ body { will-change: background-color, color; } +h1, h2, h3 { + scroll-margin-top: var(--header-height); +} + h1 { font-size: 2rem; margin-bottom: var(--spacing-lg); diff --git a/public/css/header.css b/public/css/header.css index 200c487..eb66ebb 100644 --- a/public/css/header.css +++ b/public/css/header.css @@ -4,14 +4,13 @@ header { width: 100%; background: linear-gradient(90deg, var(--header-gradient-1), var(--header-gradient-2)); backdrop-filter: blur(10px); - padding: 0.5rem var(--spacing-md); + height: var(--header-height); z-index: 1000; border-bottom: 1px solid var(--border-color); left: 0; right: 0; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); transition: var(--theme-transition), transform 0.7s ease, box-shadow 0.7s ease; - max-height: var(--header-height); transform: var(--gpu-accelerated); } @@ -22,6 +21,7 @@ header { max-width: 1100px; margin: 0 auto; padding: 0 var(--spacing-md); + height: 100%; } .logo-container { @@ -58,7 +58,7 @@ header { padding: 0.5rem 0.8rem; border-radius: var(--border-radius); position: relative; - background-color: rgba(var(--bg-hover-nav), 0.4); + background-color: rgba(var(--bg-hover-nav)); letter-spacing: 0.3px; } diff --git a/public/css/responsive.css b/public/css/responsive.css index 17d1bd9..5231d03 100644 --- a/public/css/responsive.css +++ b/public/css/responsive.css @@ -5,7 +5,7 @@ } header { - padding: 1rem; + height: var(--header-height); } .logo-text { @@ -59,11 +59,11 @@ .nav-menu { display: none; position: fixed; - top: 55px; + top: var(--header-height); left: 0; right: 0; background: var(--bg-card); - min-height: calc(100vh - 55px); + min-height: calc(100vh - var(--header-height)); flex-direction: column; align-items: center; border-bottom: 1px solid var(--border-color); @@ -98,13 +98,16 @@ /* Mobile Devices */ @media (max-width: 480px) { + :root { + --header-height: 80px; + } + .container { padding: 0 1rem; } header { - padding: 0.75rem; - max-height: 120px; + height: var(--header-height); } .logo-text { @@ -157,18 +160,16 @@ padding: 1.5rem; margin: 0; } - - .nav-menu { - top: 50px; - min-height: calc(100vh - 50px); - } } /* Small Mobile Devices */ @media (max-width: 320px) { + :root { + --header-height: 60px; + } + header { - padding: 0.5rem; - max-height: 100px; + height: var(--header-height); } .logo-text { diff --git a/public/css/variables.css b/public/css/variables.css index b393e51..2da77f4 100644 --- a/public/css/variables.css +++ b/public/css/variables.css @@ -13,8 +13,8 @@ --header-gradient-1: rgba(237, 237, 237, 0.9); --header-gradient-2: rgba(228, 228, 228, 0.9); --border-color: rgba(58, 123, 224, 0.1); - --bg-hover-rgb: 228, 228, 228; - --bg-hover-nav: 241, 241, 241; + --bg-hover-rgb: 237, 237, 237; + --bg-hover-nav: 207, 207, 207; } [data-theme="dark"] { @@ -36,7 +36,7 @@ --spacing-xl: 2rem; --border-radius: 8px; --transition-speed: 0.3s; - --header-height: 140px; + --header-height: 100px; /* Theme transition with GPU acceleration */ --theme-transition: color var(--transition-speed) ease,