1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved Stop Divi offesetting Anchor links

Discussion in 'Free Divi Community Forum' started by David McDonagh, Jun 10, 2019.

  1. David McDonagh

    David McDonagh New Member

    Hi,

    I have a Divi site which uses a transparent fixed header. I have anchor links to sections in my menu.

    I would like the link to go to the top of the section, behind my transparent header. At the moment the section starts under the header with the bottom of the previous section visible behind my header. I would like the section to be at the top of the window.

    I have been searching for solutions for many hours now and had no luck. Usually it is the opposite problem people tend to have.

    Can anyone point me in the right direction?
     
    1. PRO MEMBER PERKS Divi.Help Pro Layout Packs - Modern & powerful Agency Divi layout pack, featuring team carousel, sliding menu, etc.View Demo
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Try to add the below code in Divi > Theme Options > Integration > Body Code:
    Code:
    Log In or Sign Up to view this code.
     
    River and soulshakepower like this.
  3. David McDonagh

    David McDonagh New Member

    Works like a charm. Thank you so much!!
     
    1. PRO MEMBER PERKS Divi Block Pro - 30+ premade custom header designs for you to choose from:View Demo
  4. Dick Ockers

    Dick Ockers New Member

    AND AGAIN! Thats what I was looking for. Thank you for sharing. Stay safe!
     
  5. soulshakepower

    soulshakepower New Member

    Thank you! I've been looking for this for a long time!

    Note: For it to work I had to enable the "Alternative scroll-to-anchor method" in divi>theme options>navigation>general.
    I've also changed the menu offset value to +110 to match my header size. Thanks!
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade testimonial carousel design for your Divi site without using any plugins:View Demo
  6. johno69

    johno69 New Member

    Exactly what I needed, many thanks.
     
  7. johno69

    johno69 New Member

    Was working for me, not any more...
     
    1. PRO MEMBER PERKS Divi Powerful Child Theme - Power up your Divi sites with tons of new functionalities & premade elements:Learn More
  8. Jiri

    Jiri New Member

    This doesn't seem to work with menus built with the Divi Builder. Please advise.
     
  9. Christiane Weigel

    Christiane Weigel New Member

    Just in case anybody needs this code für responsive design, I figured out the following:


    <script>
    jQuery(function($) {

    window.et_pb_smooth_scroll = function($target, $top_section, speed, easing) {

    var $window_width = $(window).width();

    $menu_offset = -1;

    var headerHeight;

    if ($window_width > 980) {
    headerHeight = 210;
    } else if ($window_width <= 980 && $window_width > 767) {
    headerHeight = 210;
    } else if ($window_width <= 767 && $window_width > 470) {
    headerHeight = 255;
    } else if ($window_width <= 470) {
    headerHeight = 275;
    }


    if ($('#wpadminbar').length && $window_width <= 980) {
    $menu_offset += $('#wpadminbar').outerHeight() + headerHeight;
    } else {
    $menu_offset += headerHeight;
    }

    //fix sidenav scroll to top
    if ($top_section) {
    $scroll_position = 0;
    } else {
    $scroll_position = $target.offset().top - $menu_offset;
    }

    // set swing (animate's scrollTop default) as default value
    //if (typeof easing === 'undefined') {
    // easing = 'swing';
    //}

    $('html, body').animate({ scrollTop: $scroll_position }, speed, easing);

    }
    });
    </script>
     
    River likes this.
    1. PRO MEMBER PERKS Divi Ultimate Blog Plugin - Easily set awesome default design for your Divi single blog page:Learn More
  10. River

    River New Member

    Thank You !
     
  11. renoux

    renoux New Member

    Hi ... I'm sorry ... but the script doesn't work for me ...
    no problem for the classic anchor in the same page
    but when I use the link like : /home#anchor ... I always had the jump ...
    here is the site www.julien-sunier.com
     
    1. PRO MEMBER PERKS Divi Ultimate Archive Plugin - Tons of elegant premade sidebar styles to choose from for your Divi site:Learn More