Subscribe On YouTube

Join other subscribers and enjoy other Divi video tutorials!

How To Change The Divi Menu Module Hamburger Icon To An X When Open

Nelson Miller Profile Orange
This quick CSS code snippet and tutorial will change the Divi Menu Module hamburger icon into an X when the mobile menu is open.

▶️ Please watch the video above to get all the exciting details! 👆

Changing The Divi Menu Module  Icon To An X

This is going to be a short tutorial, but we all love quick and easy, right? Changing the Divi Menu Module hamburger icon into an X is a simple process. By default, the icon is part of a built-in icon font called ETmodules that comes with Divi. The default icon code for the hamburger menu is 61, and we are changing that to the X when the menu is opened, which has an icon code of 4d. So once you press the hamburger menu icon to open the menu, the icon gets replaced and it provides a better user experience.

Where To Paste The CSS Code

1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the CSS tab in the custom code window in the Divi Visual Builder.

2. Child Theme
If you are using a child theme, paste this code into the style.css file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.

3. Divi Theme Options Integration
Otherwise, paste this code in your Divi>Theme Options>Custom CSS code box.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.

/*change Divi hamburger menu to X*/
.mobile_nav.opened .mobile_menu_bar:before {
    content: '\4d';
}

That was about as easy as they come! Just one tiny snippet and the Divi Menu Module now has an X as the open icon!

Closed

Open

EDIT: In the comments, Shawn asked about how to animate this. Unfortunately it’s not possible to “animate” the icons by morphing their sizes, as these are solid icons, not vectors. So one trick that Jimmy suggests is to add a nice rotation effect. Here is the code, it looks pretty nice!

/*rotate the Divi Menu icon on click*/

.mobile_menu_bar:before {
	transition: all .4s ease;
	transform: rotate(0deg);
	display: block;
}


/*rotate the Divi Menu icon on click*/

.mobile_nav.opened .mobile_menu_bar::before {
	transition: all .4s ease;
	transform: rotate(90deg);
	display: block;
}

Subscribe For More Things Like This!

At the start of each month, we send out a recap newsletter from the month before with family news, Divi news, our latest tutorials, and product news. Occasionally, if the news is too exciting to wait, we will send out another email separate from the monthly newsletter. That’s what you get when you subscribe, and of course you can unsubscribe if you are no longer interested!

Blog Post Optin

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

64 Comments

Comments By Members

  1. Sean Craig <span class="comment-author-role-label"><a href="https://wordpress-292293-1617718.cloudwaysapps.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Thanks for this!
    Just a quick note. Your snippet needed a \ for me to make it work. Thought I’d share you so you can update your blog.

    Reply

Comments By Others

  1. Mikala

    Thank you for this, works like a charm 😉

    Can the same be done for the logo?
    A different file with a different color than before opening the menu? Or is it some JS that is necessary?

    As always, great tutorials. Thank you 😀

    Reply
  2. Hemant Gaba

    Hi Mikala!

    Please add the following code instead of the above one:

    .mobile_nav.opened .mobile_menu_bar:before {
    content: ‘\4d’;
    color: red;
    }

    Change the color in the code as per your requirement.

    Reply
  3. Hemant Gaba

    Hi Mikala!

    The icon code is no correct in the code you shared. Please use the following code and see if it helps:

    #et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before,
    .et_pb_module.et_pb_menu .et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before {
    content: ‘\4d’;
    }

    Reply
  4. Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

    I do not understand. The code in this tutorial is about replacing the icon, so if the icon is different for open state, then it will show the other icon. Maybe some cache issue?

    Reply
  5. beatriz

    Thanks, I had the same problem on some devices and that worked

    Reply
  6. Maddy Seeley

    Thank you so much for that! Worked perfectly.

    Reply
  7. Pavol

    I have same the same issue. Any solution? It is also combined with mobile full screen menu css.

    Reply
  8. Hemant Gaba

    Hey Maddy,

    Please find the code given below and remove it. Your problem will be solved.

    .pa-fullscreen-menu .opened .mobile_menu_bar {
    position: fixed!important;
    }

    Let me know how it goes.

    Reply
  9. Hemant Gaba

    Hey Maddy,

    Could you please share the URL of the website for me to investigate it further?

    Reply
  10. Jemma Pollari <span class="comment-author-role-label"><a href="https://wordpress-292293-1617718.cloudwaysapps.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi Nelson, I am trying to do this (changing the icon of one menu while leaving the other as a hamburger).

    I’ve added the class
    top_bar_menu

    to the menu module I want to change, and the code:

    .top_bar_menu:before {
    content: ‘\e08a’;
    }

    into Divi > Theme Options > Custon CSS

    but it doesn’t work. Am I using the custom class in the right way?

    Reply
  11. Hemant Gaba

    Hey Nasroo,

    I have checked the website and I am not able to replicate the issue on my end.

    Reply
  12. Oliver Gehrmann

    This is all the code you need (there’s 2 display: block; statements, one of which is not necessary; there’s also 2 transition statements, one of which is not necessary, etc.):

    .mobile_menu_bar::before {
    display: block;
    transition: all .4s ease;
    }
    .mobile_nav.opened .mobile_menu_bar::before {
    content: “M”;
    transform: rotate(90deg);
    }

    But thanks for this great suggestion Jimmy, it works like a charm!

    Reply
  13. Hemant Gaba

    Hey Louise,

    We appreciate your feedback but in the guide it is stated as \4d for the cross sign so is there anything we are missing out here?

    Reply
  14. Hemant Gaba

    Could you please share the URL of the website where the Menu is placed for us to investigate further?

    Reply
  15. Milan
    \4d
    

    worked for me 😉

    Reply
  16. Jimmy Lemon

    Shawn, try this CSS.

    /* Animate divi mobile icon on click / switch out */

    .et_pb_menu_0_tb_header .mobile_nav .mobile_menu_bar:before {
      transition: all .4s ease;
      transform: rotate(0deg);
      display: block;
    }

    #et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before, .et_pb_module.et_pb_menu .et_mobile_nav_menu .mobile_nav.opened .mobile_menu_bar::before {
      transition: all .4s ease;
      transform: rotate(90deg);
      display: block;
    }

    Reply
  17. Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

    Hi Fernando,
    Any time you want to target specific modules rather than all of them you need to add a custom class. So add a class to the one menu module and match that same class in the snippet.

    Reply
  18. Mike Nelson

    I guess the Icon codes have changed. where do I find the current icon codes? Meaning where can I find the code for each icon

    Reply
  19. Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

    Hi Mike,
    So you are asking how to do that? You would just find the icon from ETModules and add that, just like this tutorial just leave out the opened part .mobile_nav.opened

    Reply
  20. Henry

    Me, too. Thanks, Sean!

    Reply
  21. Chip

    That’s right. I can confirm that.

    Reply
  22. Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

    Hi there, I’m very confused what you are doing, but it sounds like you would need Jquery or something to change the state first, then change the icon with CSS for each state.

    Reply
  23. Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

    Hi Tim,
    I’m glad you like my tutorials! Can you explain what you mean about the time? If you are referring to a transition it won’t work, since this is a pseudo-class content.

    Reply

Leave a Reply to Alex Cancel reply

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

Recent Posts

0

Your Cart