-
Stefanie
Hi team,
on this page the upper picture (featured image) was linked and jumps to the title of the page.
The link should be equipped with smooth-scroll.But where should I set this? If I assign the class smooth-scroll to the image, then not the link gets this class, but the image itself.
And then of course it does not work with smooth-scroll.
How do you have to do it?
Thank you!
-
Alvind
Hi there,
Try adding the link and the class to the container that wraps the image, rather than to the image itself.
-
Stefanie
Hi there,
thanks that works.
But unfortunately the link ends up way too far down and the header then covers the headline.I have this css in my child theme, but it doesn’t seem to do anything…
[id] { scroll-margin-top: 56px; } -
Can you remove the
smooth-scrollclass from the image?Let me know when it’s done.
-
Stefanie
-
Can you remove the
smooth-scrollclass, no matter where it was added? -
Stefanie
Ok, yes I did that now.
-
Now the
scroll-margin-topCSS works.So from now on, do NOT use the
smooth-scrollclass anymore, as now browsers can smooth scroll with just CSS:html, body { scroll-behavior: smooth; } -
Stefanie
Thanks for your answer.
But I only want to use the
scroll-behavior: smoothfor certain links, not for the entire site.
The navigation, for example, should also jump to certain IDs, but not with smooth.How can I set it so that it only applies on this page (in this Element) for the #title?
-
In this case, you need to use
smooth-scrollclass as it’s triggered by JS.But it conflicts with the
scroll-margin-topCSS, so you will need to write custom JS to overcome this issue, or use GP’s sticky navigation. -
Stefanie
But it conflicts with the scroll-margin-top CSS, so you will need to write custom JS to overcome this issue
I see.
Then it remains with “hard scroll”.Thanks 🌷
-
You are welcome 🙂
- You must be logged in to reply to this topic.