How to Build a Stagger-Animated Hamburger Menu with Divi & Anime.js | Elegant Themes Blog

In the past, we’ve shared different types of headers you can create with Divi and the Divi Theme Builder. As a matter of fact, you can find all of those tutorials listed in this navigation post. In that post, you’ll notice we’ve shown you how to create a fullscreen header, but to help you take your header design even further, we’ll show you how to create a custom-animated hamburger menu as well. There are a few notable things about the hamburger menu we’ll create:

In other words, this is definitely a header tutorial that’ll help you add that advanced look and feel to your website. You’re able to style the items however you want as well and you’ll be able to download the JSON template file for free!

Let’s get to it.

Download The Global Header Template for FREE

To lay your hands on the free global header template, you will first need to download them using the button below. To gain access to the download you will need to subscribe to our Divi Daily email list by using the form below. As a new subscriber, you will receive even more Divi goodness and a free Divi Layout pack every Monday! If you’re already on the list, simply enter your email address below and click download. You will not be “resubscribed” or receive extra emails.

Join the Divi Newsletter and we will email you a copy of the ultimate Divi Landing Page Layout Pack, plus tons of other amazing and free Divi resources, tips and tricks. Follow along and you will be a Divi master in no time. If you are already subscribed simply type in your email address below and click download to access the layout pack.

You have successfully subscribed. Please check your email address to confirm your subscription and get access to free weekly Divi layout packs!

1. Create New Header Template

Go to Divi Theme Builder & Add New Global Header Template

Start by going to the Divi Theme Builder. One there, add a new global header.

Start Building From Scratch

And start building the header design from scratch.

2. Build Logo & Hamburger Icon

Section Settings

Once inside the template editor, we’ll start by building the logo and hamburger icon. You’ll notice there’s already a section there. Open the section settings and apply a transparent background color.

Then, go to the advanced and turn the section fixed.

Continue by adding a new row to the section using the following column structure:

Remove all default top and bottom padding next.

Main Element CSS

And to make sure both the logo and hamburger icon appear next to each other on smaller screen sizes, we’ll insert one line of CSS code in the row’s main element.

Add Image Module to Column 1

Upload Logo

Time to add modules, starting with an Image Module in column 1. Upload a logo of your choice.

Then, reposition the entire module.

Add Text Module to Column 3

HTML Structure in Content Box

In the third column, we’ll add a Text Module. We’ll use this Text Module to create our hamburger icon. Start by switching over to the text tab in the content box and insert the following HTML tags:

Reposition this module as well.

3. Build Hamburger Menu

Now that we have the logo and hamburger icon in place, we can move on to the next part which is dedicated to building the hamburger menu and all its items. Start by adding a new section, open the section settings and apply a gradient background.

To make sure the menu can be opened at all times, we’ll reposition the section in the advanced tab.

Continue by adding a new row to the section using the following column structure:

Reposition the row as well.

We’ll apply some border settings too:

Column 2 Settings

Then, we’ll move on to column 2 and apply some custom padding values there too.

Add Text Module #1 to Column 1

Add H3 Content

Time to add modules, starting with a first Text Module in column 1. Add some H3 content of your choice.

H3 Text Settings

Move on to the design tab and change the H3 text settings as follows:

Clone Text Module & Place Duplicate in Column 2

Once you’ve completed this first module, you can clone it once and place the duplicate in column 2.

Change Content

Make sure to change the content in this duplicate module.

Add Text Module #2 to Column 2

HTML Structure in Content Box

To showcase our menu items, including sub menu items, we’ll use the text tab of a new Text Module. Go ahead and add a new Text Module to column 1 and insert the following HTML:

Text Settings

Move on to the module’s design tab and change the text settings as follows:

Link Text Settings

Change the link text color too.

Unordered List Text Settings

Then, modify the unordered list text settings.

And complete the module settings by adding some custom top and bottom padding.

Clone Text Module to Create Variation Without Submenu

Once you’ve completed the first module, you can clone it once. We’ll use this duplication to create a variation of the menu item without sub menu items.

Leave Out Submenu & Toggle Icon

To turn this duplicate module into a regular menu item without submenu items, use this HTML structure instead:

Reuse Both Types of Menu Items

Once you have both variations of the menu items in place, you can reuse both of them accordingly by cloning them and changing the content.

Add Text Module #2 to Column 2

Add H4 & Paragraph Content to Content Box

In column 2, we’ll add another Text Module with some H4 and paragraph content of our choice.

Text Settings

Move on to the design tab and change the text settings accordingly:

H4 Text Settings

Make some changes to the H4 text settings too.

Then, modify the module’s width in the sizing settings.

Main Element CSS

And add one line of CSS code to the module’s main element. This line of CSS code will help us place two Text Modules next to each other.

Clone Text Module #2

Once you’ve completed the Text Module, you can clone it once and change the content accordingly.

Add Social Media Follow Module to Column 2

Add Social Networks of Choice

The last module we need in this design is a Social Media Follow Module in column 2. Add the social networks of your choice.

Remove Each Social Network’s Background Color Individually

Remove the background color of each social network individually.

Then, go back to the general module settings and apply some top margin.

4. Add Functionality

Add CSS Class to Hamburger Icon Text Module

Now that the foundation of our hamburger menu design has been built, we can now focus on adding functionality! The first thing you’ll need to do is open the Text Module containing the hamburger icon and add the following CSS class:

Add CSS Class to Section #2

Then, open the hamburger menu section, section #2, and add the following CSS class:

Add CSS Class to Each Module in Fullwidth Menu

To create the custom stagger animation effect, we’ll need to apply the following CSS class to each module in section #2.

Add Extra CSS Class to Menu Items

Add an extra CSS class, called “main-menu-item”, to each one of the menu items in column 1 as well.

Add Code Module to Section #1

To apply the functionality, we’ll use custom CSS and JQuery code. We’ll place this code in a new Code Module in the second column of our row in section #1.

Insert CSS Code

Add the following CSS code to the Code Module in between style tags as you can notice in the print screen below.

Insert Anime.js Library

Continue by adding the Anime JavaScript library using script tags as you can see in the print screen below. We’ll use this awesome library to create the stagger effect in the next step of the tutorial.

Insert JQuery Code

The click functionalities in our hamburger menu are powered by the following JQuery code. Make sure you place this code in between script tags as you can see in the print screen below.

Activate CSS Class as Soon as You’ve Completed Your Fullscreen Header Design

Last but not least, we’ll enable a CSS class in the Code Module which you can find in the first section. Open the Code Module and remove the “/* */” at the beginning and end of the class. Enabling this class (in combination with some JQuery code that’s already enabled) will make sure the section containing the menu items doesn’t load right away when someone visits one of your pages. Once you enable this class, the second section on your page will disappear from the Visual Builder, but you can still access it in the Wireframe Mode or turn off the CSS class if you want to make additional changes.

5. Save Header & Theme Builder Changes

That’s it! The only thing left to do is save the template and Divi Theme Builder and view the outcome on your website!

In this post, we’ve shown you how to get creative with your Divi header. More specifically, we’ve shown you how to create a custom-animated hamburger menu. As soon as a visitor clicks on the hamburger icon, a fullscreen menu transitions in and reveals the menu items one by one, which results in a beautiful user experience. You were able to download the template JSON file for free as well! If you have any questions, feel free to leave a comment in the comment section below.

If you’re eager to learn more about Divi and get more Divi freebies, make sure you subscribe to our email newsletter and YouTube channel so you’ll always be one of the first people to know and get benefits from this free content.

This content was originally published here.