Web Design, Elementor
November 5, 2023
Kyle Altenderfer

Elevate Your Elementor Designs: Implementing a Custom Scroll Top Offset

Enhance your Elementor web designs by implementing a custom scroll top offset – the solution for seamless navigation with sticky headers. Our tutorial makes it simple.

Table of Contents



In the world of web design, the devil is in the details. Those details can mean the difference between a site that’s just functional and one that provides a seamless, intuitive user experience. For WordPress users, Elementor has emerged as a powerful tool in crafting such experiences. However, there’s a common hiccup when it comes to navigation: the sticky header overlap. But fear not, we have a JavaScript snippet that will streamline your navigation with a global scroll offset – and it’s easier than you think to implement.

Before we dive into the code, let’s set the stage for why this is crucial. Imagine you’ve got a beautifully designed website with a sticky header that remains at the top as users scroll down. It’s practical, keeps navigation at your user’s fingertips, and frankly, it looks good. But here’s the rub: when you use Elementor’s menu anchor widget for one-page navigation, your content might hide behind that sticky header, frustrating users and disrupting the flow of your design. Our solution? A custom JavaScript code that adjusts the scroll-to position across the entire site.

Here’s a step-by-step guide to ensure your users never lose their way:

The Code Unveiled

We’ve made a modification to the standard script you might find in Elementor tutorials. Instead of limiting this functionality to product pages, we’ve broadened its application to the whole site. This means, no matter where you apply your anchors, the scroll will always account for the header.


add_action('wp_footer', function () {
    // Only proceed if Elementor is loaded.
    if (!defined('ELEMENTOR_VERSION')) {
    // Custom JavaScript to adjust the scroll-to position
        // Initializing our function when Elementor front-end is ready
        window.addEventListener('elementor/frontend/init', function () {
            // Adding a filter to modify the scroll top distance
            elementorFrontend.hooks.addFilter('frontend/handlers/menu_anchor/scroll_top_distance', function (scrollTop) {
                // Subtracting the height of the sticky header
                // Change the '140' to match your sticky header's height
                return scrollTop - 140;


Commenting for Clarity

Each line of code includes a comment to explain its purpose, ensuring that even those new to coding can understand and modify it as needed. Remember, the ‘140’ is the pixel value of the sticky header’s height. If your header is taller or shorter, you’ll want to adjust this number to fit.

Integrating with Elementor

Implementing this snippet is a breeze. You can add it to your theme’s functions.php file, a custom plugin, or use a code snippets plugin to inject it into your site’s footer.

Seeing It in Action

Once you’ve added the code, it’s time to test. Create a menu anchor in Elementor, link to it from your navigation menu, and watch as the page scrolls perfectly to position, with your content neatly below the sticky header, not hidden behind it.

In Conclusion

Customizations like these are what take a site from good to great. They show your attention to detail and your commitment to the user experience. This simple tweak is just the beginning of what you can achieve with Elementor and a little bit of custom code.

Final Thoughts

The journey to web design mastery is an ongoing one, with new tools and tricks always emerging. By fine-tuning your use of Elementor with custom scripts like the one we’ve shared, you’re well on your way to creating standout, user-friendly websites that work perfectly. Remember, a sticky header should never stick out as a problem, but seamlessly integrate into your design—and now, it can.

Ready to refine your website’s navigation and ensure every scroll is spot on? Dive into our tutorial, and take control of your web design destiny with Elementor.