Skip to main content
All CollectionsTroubleshooting and FAQsFrequently Asked QuestionsHeader and Footer Areas
How to Create a Fixed Navigation that Sticks to the Top When the Page is Scrolled Down
How to Create a Fixed Navigation that Sticks to the Top When the Page is Scrolled Down

Learn how to build a Sticky Navigation Bar from Bottom to Top in Divi by using Divi's built-in features and applying custom CSS.

Updated over 4 months ago

Enhancing your website’s navigation by making it stick to the top of the page as users scroll can improve accessibility and user experience.

In this article, we will guide you through the process of creating a fixed navigation bar that remains at the top of the screen when the page is scrolled down using Divi.

Disclaimer: This will work with only one Section in the Global Header Layout.

Create the Layout using Theme Builder

  1. Go to WordPress Dashboard → Divi → Theme Builder

  2. Click on the Add Global Header option

  3. Choose the Build Global Header option

Step 1. Edit the Section's settings

  1. Open the Section's setting by clicking on the Gear Icon

  2. Go to Content Tab Background Background color and set a transparent color

    Divi - Section background color

  3. Go to the Design Tab → Sizing and set the following options:

    1. Width: 100%

    2. Max Width: 100%

    3. Min Height: 100vh

    Divi - Section Sizing options

  4. Go to the Design Tab → Spacing → Padding and set the following values:

    1. Padding Top: 0

    2. Padding Bottom: 0

    Divi - Section Spacing options

  5. Go to the Advanced Tab → CSS ID and set it to dt-site-header

    Divi - Section CSS Class

  6. In the Advanced Tab → Position, set the following options:

    1. Position: Absolute

    2. Location: Top Center

    Divi - Section Position options

Step 2. Add and edit the Row's settings

  1. Click on the Green Plus Icon to add a 1 Column Row

  2. Edit the Row's setting by clicking on the Gear Icon

  3. Go to the Content Tab → Background → Background Color and set it to White

    Divi - Row Background options
  4. Go to the Desing Tab Sizing and set the following values

    1. Width: 100%

    2. Max Width: 100%

    Divi - Row Sizing options
  5. Go to the Advanced Tab → CSS ID and set it to dt-menu-wrapper

    Divi - Row CSS ID options

  6. Go to Advanced Tab → Position and set the following values:

    1. Position: Absolute

    2. Location: Bottom Center

    Divi - Row Position options

Step 3. Add the Menu module

  1. Switch to Wireframe mode by clicking on the Wireframe Icon

    Divi - Wireframe mode

  2. Click on the Plus Dark Grey Icon and add the Menu module. Configure it to your liking.

    Divi - Add the Menu module

  3. Click on the Green Plus Icon to insert a new Row into the existing Section

  4. In this new Row, click on the Plus Dark Grey Icon and insert two Code Modules

    Divi - Add a second Row

  5. Edit the second Row's settings by clicking on the Gear Icon

  6. Go to the Content Tab → Admin Label and type in Utils Row

    Divi - Row Admin Label options

  7. Go to the Design Tab → Sizing and enable the Use Custom Gutter option

  8. Set the Custom Gutter Width to 1

    Divi - Row Custom Gutter Width options

  9. Open the first Code Module and paste the following JS code:

    <script>
    jQuery(function ($) {
    var headerHeight = $('#dt-site-header #dt-menu-wrapper').outerHeight();
    $(window).bind('scroll', function () {
    var windowHeight = $(window).height();
    if ($(window).scrollTop() < windowHeight - headerHeight) {
    $('#dt-site-header').removeClass('dt-fixed');
    } else {
    $('#dt-site-header').addClass('dt-fixed');
    }
    });
    });
    </script>

  10. Open the second Code Module and paste the following CSS code:

    #dt-site-header.dt-fixed {
    position: fixed !important;
    }

    .dt-fixed #dt-menu-wrapper {
    position: fixed !important;
    bottom: auto;
    top: 0;
    }

  11. Save your changes and exit the Visual Builder

  12. Save the entire Theme Builder by clicking on the Save Changes button

The result will be that the Global header will be at the bottom of the page, and once it reaches the top of the browser window, it will be Fixed at the top.

The complete layout can also be downloaded from the link below:

Attachment icon
Did this answer your question?