🎁 Get Up To 70% Off and a Free Prize During Divi Black Friday Sale! Get Divi

How to Increase the Width of the Divi Header on Scroll

Blog, Divi Tutorial | 0 comments

In this tutorial we will add a transition effect to the Divi Header. In this effect the width of the Divi Header will increase when you scroll down adding a smooth transition effect to it. You can have a look at the GIF below to preview the end result.

Divi fixed header increase width effect

Now that you have you seen the preview lets get to the code.

Default Divi Header

Adding this effect to the default Divi Header is pretty simple. All you need to do is add the following code to your WordPress Dashboard > Divi > Theme Options > Custom CSS

.container.clearfix.et_menu_container {
    -webkit-transition:1s;
    -o-transition:1s;
    transition:1s;
    -webkit-transition-timing-function:ease;
         -o-transition-timing-function:ease;
            transition-timing-function:ease;
}

.et-fixed-header .container.clearfix.et_menu_container {
    width:90%;
    max-width:100%;
}

And that’s it we are done. You can change the 1s value in the code to increase the duration of the transition.

You can also change the transition function. To learn more about transition timing functions I will recommend that you check out the article from CSS-Tricks.com. They have done a really great job at explaining it.

Header Built Using The Theme Builder

If you are using a header that is built with the Theme Builder then the code shared above will not work.

In order to add the same affect to a custom header we will need to perform a few extra steps. If your header built with the Theme Builder is not already Fixed then please check out tutorial How to Make the Custom Divi Header Fixed or Sticky

First of all you need to open the Section Settings and add the CSS ID main-header to the Section that contains the menu. The CSS ID needs to be added in the Section Settings > Advanced > Custom CSS ID & Classes > CSS ID

Adding a CSS ID to Section Settings in the Divi Builder

After adding the CSS ID to the Section go to your WordPress Dashboard > Divi > Theme Options > Integration > Add code to the < head > of your blog and add the following code.

<script>
jQuery(function($){
$(function() {
    //caches a jQuery object containing the header element
    var header = $("#main-header");
    $(window).scroll(function() {
        var scroll = $(window).scrollTop();

        if (scroll >= 100) {
            header.addClass("et-fixed-header");
        } else {
            header.removeClass("et-fixed-header");
        }
    });
});
});  
</script>

After adding the jQuery code above add the following CSS code to your WordPress Dashboard > Divi > Theme Options > Custom CSS

#main-header .et_pb_row {
    -webkit-transition:1s;
    -o-transition:1s;
    transition:1s;
    -webkit-transition-timing-function:ease;
         -o-transition-timing-function:ease;
            transition-timing-function:ease;
}

#main-header.et-fixed-header .et_pb_row {
    width:90%;
    max-width:100%;
}

The code you just added will work on both a Standard Section that contains a standard Row and also with Fullwidth Section that contains a Fullwidth Menu Module.

Leave a comment below if you found this helpful or have any questions. Don’t forget to subscribe to the Newsletter to receive the latest tutorials in your inbox.

About the Author

The author of learnhowwp.com is a WordPress expert with over a decade of experience, specializing in Divi. Since 2014, they have built numerous WordPress sites and developed 8 Divi plugins with over 30,000 active installations. A former support team member at Elegant Themes, they launched learnhowwp.com in 2020 to share their in-depth knowledge of Divi. Now home to over 65+ articles dedicated to Divi tutorials and insights

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Our Plugins Are Already Being Used On 30,000+ Amazing Websites.

We offer a 30 Day Money Back Guarantee on all plugins, so joining is Risk-Free!