Closed fromITzerotoIThero closed 1 year ago
That's a known issue - id navigation plus sticky/fixed header is a recipe for headaches. However, you should beware - trying to band-aid over it with scrolling on navigation will only cause you more trouble, besides hijacking scroll is generally considered a no-no. Instead, surprisingly paddings and margins are a better solution for that, with a bit of a trick:
position: relative
and the child position:absolute; top: -60px
Maaaan, so good you're there! You saved me a ton of time!!!
If you want to experience the pain of hijacking the scrolling, then we can do it one day as an exercise, but for now let's focus on delivering.
Oh I love simple solutions just like the one you showed me :) Hijacking scrolling - a painful, yet valuable lesson I'd love to take, but in the future ;) Thank you for all your priceless help!!!
Sorry to resurrect an old discussion, but I just found out a more elegant solution for the sticky header anchor scroll problem https://moderncss.dev/12-modern-css-one-line-upgrades/#scroll-margin-topbottom I'm not saying that you should implement it, or even consider it, but I'm just dropping it here for future reference in case you will come across the issue ever again.
Dear W.,
So I have this issue - when navigating to different sections of the website (which btw works great with the library you recommended :) the sticky header hides the header of the section, which looks bad:
but, I have 2 questions I can't find the answers on the net: