Divi is a really great theme with a lot of flexibility. However, the drop-down menu is something we quickly have had enough of. Often you can identify that a page is using Divi just by looking at the menu. The colored line below it, the distances, the hover color. We never fully understood why so many people spend so much time on creating good liking layouts but barely take care of the default look and feel of their menus.

In this post, we want to show you a really cool alternative to the boring default drop-down and give you an example of how you can style your Divi menu to not only look way cooler than the average but also show you some neat little tricks for styling WordPress menus in general. For this, this post is separated in 3 sections:

  • Using Divis mega-menu
  • Styling the drop-down menu
  • Adding custom images and icons to your menu

The Divi Mega Menu

It’s sad that there is no setting or even a hint in the theme customizer that this exists (well maybe there is something in the documentation but who has time to read that, am I right?). We used Divi for about one and a half year when we first heard about this awesome treasure, hidden in the depths of the themes code.

The mega menu basically lets you create a single full-width drop down with multiple submenus inside it and visible at the same time. Yes, the menu on this site is a mega-menu as well – a custom styled, though. To activate the mega-menu, all you have to do is to add “mega-menu” to your menus top level menu entries CSS classes. Keep in mind that it works best if you have 3 levels of menu entries. The first level gets the “mega-menu” class. The second levels are then the “categories” and the third level are the entries.

Check out the menu structure for our page. “Menu” is the top level entry (by the way, you can have multiple top level entries with the “mega-menu” class). The second level are the “categories” like blog, themes and modules. The third level are then the entries which are listed under the categories (e. g. the blog categories under the blog section).

By the way, if you don’t have the CSS field in your menu, you have to activate it in the Screen Options. Generally, the Screen Options are often overseen and are available in a lot of different places. You should check them out more often. πŸ˜‰

That is basically it. You are now able to use the Divi Mega Menu. It is indeed that simple. However, it will look different to what our menu looks like. Probably more that. Thats because we added some CSS to style our menu. Which brings us to the next section.

Styling the drop-down menu

There are various tutorials on how to style the WordPress navigation. However, we want to show you how we styled ours. At this point, we would like to thank and credit Geno Quiroz, from who we have gotten most of the styling. He has an awesome tutorial to style the mega menu here.

Heres the customization he came up with:

Please note that we already applied our primary color and some other color changes here. Well, that alone might work for his page or the sake of the tutorial he wrote but this brings a few downsides. Lets look at what happens if we only apply this CSS:

As you see, the mega menu looks slimmer already but what about the default dropdown? The first level indeed looks okay as well but if you have a sub-menu in there, it totally breaks the menu. So lets fix this by adding the following CSS. Notice that we use the “:not()” pseudo element to explicitly exclude the mega-menu from using these styles.

This will put subsequent sub-menus on the right place. It also adds back the functionality to open sub-menus to the left when there would not be enough space otherwise.

Next lets tackle the blue line. Though it might work for your page, it not only is a first class indicator that you are using Divi but it also makes every Divi page somehow look the same and maybe you or your clients just don’t like it. So lets get rid of it. We do that by removing the top border from the sub-menu. Add the following to your CSS:

This will remove the border on the mobile menu as well but if you only want to remove it on the desktop, use the #top-menu-nav instead the #et-top-navigation. Now since we removed the border, the sub-menus are missing 3px of height so go back to the “#top-menu li li ul” selector and change “top:Β -3px;” to “top:Β 0px;”. Now the sub-menus are back in place.

We find, that the link should fill the whole sub-menu so add this CSS code as well:

The result looks like this and we are pretty happy with it:

There is only one thing which really annoys us. As soon as you are not hovering accurately over the top level entries, the drop-down is collapsed immediately. If you are looking for a fix for this issue, you should checkout the tutorial we have written on this topic: prevent Divi Mega Menu from collapsing.

The last thing we like to style is the current selected page in the mega-menu. By default, Divi overwrites the current selected page with a blue color but we also want to show off the ancestor of the currently selected page. Therefore we added this CSS:

Adding images and icons to your menu

If you want to add a visual pleasing decal to your menu, you have basically two options. You can use images are a icon font like Font AwesomeΒ or Divis builtin one which is called “ETmodules”. You then again have two options on how to get that into the menu. You either can use HTML (most people don’t know that you can use html in the menu titles field) or CSS.

The HTML Way

The HTML way is probably the easier approach. Simply create a <img> tag with your desired image and add it to the menus Navigation Label.

You can either stlye the image inline or you could use the CSS Classes field to add additional classes so you can target your image. In this case, you could use one of these selectors to select the image:

  • .mega-menu img
  • .menu-item img
  • #top-menu a img

A good idea could be for example to vertically align the image with the text, change it’s size or do whatever else pleases you.

The second option is using :before or :after pseudo elements to add content manually. That is by the way how we did things in our menu. First, we added a bunch of classes to our second menu level (blog, etc.) and then used this CSS to add the icons using Divis icon font.

Whats that square you might ask – depending on which browser you are currently using. Well, thats the unicode character used by the icon font. Though they look the same since the browser does not know how to render them appropriately, they are in fact different. If you wonder where you can get them from, simply fire up the Divi Builder, open a module with a icon field (like the Button or Blurb module) ad open your browsers element inspector. By inspecting the icons, you can out the unicode character to use.

Now it’s just a matter of copy and paste the character from the data-icon field to your CSS.

Coclusio