1. HOT Divi Ultimate Header Plugin - Design Divi custom header globally in Divi Builder: https://header.diviultimate.com/

Solved Stop Divi offesetting Anchor links

Discussion in 'Get Help On Divi Wordpress' started by David McDonagh, Jun 10, 2019.

  1. David McDonagh

    David McDonagh New Member


    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?
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Try to add the below code in Divi > Theme Options > Integration > Body Code:
    jQuery(function($) {
        window.et_pb_smooth_scroll = function( $target, $top_section, speed, easing ) {
            var $window_width = $( window ).width();
            $menu_offset = -1;
            if ( $ ('#wpadminbar').length && $window_width > 600 ) {
                $menu_offset += $( '#wpadminbar' ).outerHeight();
            //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 );
  3. David McDonagh

    David McDonagh New Member

    Works like a charm. Thank you so much!!