Archived topic
Jump from page wrong position due to sticky header
11 replies · Started by Damiaan van Vliet on February 8, 2021
Good morning team,
I have a site with a page which has anchor links on e.g. section01, section02, section03.
When I scroll on the page itself to a section, everything works fine.
But when I jump from another page to a section on that page, the sticky navigation is above text.
So I jump from the /testpage01 to /testpage02 like this:
/testpage02/testpage02/#section02
I've tried a "scroll a little back" jQuery script but it did not help me.
What's the best I can do? I will place in the private info box more info.
Hi there,
can be dome with some JS but the simplest option would be to switch the layout a little, by adding more space to the top of the section.
Currently i see each of your sections has a Line Separator below its content. What if you just switched it around, ie. each section began with the Line Separator ? This would give you the extra headroom to stop the title from disappearing behind the sticky nav.
Hi David, I've tried that and indeed that's working, thanks! So it is solved when the client also think this is a good solution, I will ask him.
Is it doable to share a JS script you have on the shelf? Or point me in what direction I have to Google. I want to try it. :-)
One of our users went for this solution ( i haven't tested ):
https://generatepress.com/forums/topic/anchor-links-load-behind-sticky-header/#post-991786
Great David! Thank you very much.
You're welcome
Oh David, the script from user Drew works very good! So topic double solved. :-)
Awesome - glad to hear that :)
@Damiaan van Vliet,
How did you apply for that sctipt?
Hi Tertas,
inserted into a wp_head hook element and applied to the entire site.
Seems the user Drew added the code in this way.
You can add a hook element at appearance > elements.
thanks
No Problem :)