Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Linked featured image should be equipped with the class smooth-scroll

  • 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!

  • Hi there,

    Try adding the link and the class to the container that wraps the image, rather than to the image itself.

  • 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-scroll class from the image?

    Let me know when it’s done.

  • Hi Ying,

    the image has no smooth-scroll class.

    I did it the way Alvind suggested.

  • Can you remove the smooth-scroll class, no matter where it was added?

  • Ok, yes I did that now.

  • Now the scroll-margin-top CSS works.

    So from now on, do NOT use the smooth-scroll class anymore, as now browsers can smooth scroll with just CSS:

    html, body {
        scroll-behavior: smooth;
    }
  • Thanks for your answer.

    But I only want to use the scroll-behavior: smooth for 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-scroll class as it’s triggered by JS.

    But it conflicts with the scroll-margin-top CSS, so you will need to write custom JS to overcome this issue, or use GP’s sticky navigation.

  • 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   🙂

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.