Emulate scroll-margin-top CSS property

Hello,

I’m trying to use anchor links to navigate through a page, but whenever the link is clicked the section ends up covered by the sticky header. See example here:

I’ve tried using the CSS property “scroll-margin-top” but it isn’t recognized, I think it’s because smooth scrolling is handled through javascript. How can I achieve a similar effect (being able to define the margin top when scrolling through an anchor link)?

The issue is a bit more complicated than shown in the example, as the problem is happening in another page: https://savantwms.oriolremolina.com/features/

Where I have not only the sticky header, but also a sticky section. In this case the Accordion element (created in the included WP Bakery Page Builder) sections scroll to the top when active, but are being covered by the sticky section above. I’d like to be able to define the scroll margin top when the section is active.

Thank you,
Oriol Remolina

Hello Oriol Remolina,

Thanks for writing in! You have a sticky header. It is best that your ID should be added to the section so that when you set the link anchor, it will be perfectly placed right below the sticky header once the link anchor or button is clicked. You may also refer to the One Page navigation documentation here: https://theme.co/docs/setup-one-page-navigation

Best Regards.

Thanks, I am aware of how navigation within the same page works, what I need is a way to change the margin that is left from the top of the viewport (as the CSS property “scroll-margin-top” would work).

The CSS property “scroll-margin-top” does not work with the theme, I believe because scrolling is handled by js. If this is the case, I’d like to know how to configure certain items to have additional margin when scrolled to.

Thank you again,
Oriol

Hi Oriol,

On this page, it looks like you applied the id on the Text element (https://i.imgur.com/XWlk6kf.png).

Can you try applying the ID on the Section itself?

Thanks,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.