How to Easily Create a Divi Menu Button in Divi 4.0+

by | Nov 23, 2020 | Divi Tutorials | 53 comments

Welcome to D I V E M B E R (Divi + November) here at Divi Life! All month long during November we’re going LIVE on Facebook & YouTube, and publishing new tutorials, freebies, new product features, new product releases, and more! Make sure you subscribe to our email list so you don’t miss any of the action or awesome free stuff! And, follow us on Facebook & YouTube to be notified when we go LIVE.

In today’s tutorial, I’m going to show you how to add a call to action button to your Divi Menu!

This method words on the default header, AND headers/menus that are created with the Divi Theme Builder (Divi 4.0+).

How to Add a Call to Action Button to Divi Menu

  1. Add the CSS Class divi-life-cta-menu to the Menu Item
  2. Add the CSS Code to Style the Link to Look Like a Button
  3. Optional: Add our “Attention Grabber” CSS to Grab User’s Attention

Sounds simple right? It really is! Let’s dive in!

Step One: Add the CSS Class divi-life-cta-menu to the Menu Item

Go to WP Admin > Appearance > Menus, and turn on the CSS Classes option in Screen Options.

Then, open up the menu item you’d like to transform into a button, and paste the CSS class divi-life-cta-button as shown in the screenshot below:

Step Two: Add the CSS Code to Style the Link to Look Like a Button

Now that the CSS class has been added, we can now add the CSS code. Copy and paste the CSS code below to the custom CSS box within Divi Theme Options, or in your Divi Child Theme.

.divi-life-cta-menu a {
  background-color: #44ceb0;
  padding: 15px 25px !important;
  border-radius: 25px;
  text-transform: uppercase;
  color: #fff !important;
  text-align: center;
}

That’s it! Once that’s saved, your menu link will now be a menu button! You can of course customize the color, padding, and border radius, by adjusting the CSS.

Step Three: (Optional) Add our “Attention Grabber” CSS to Grab User’s Attention

Call to Action buttons in the menu have become extremely common. While they’re intended to stand out from the rest of the menu, they don’t have the same impact as they used to since users have grown so accustomed to them. (sort of like ad blindness!)

So how do we make them standout? We add some slick animations! But be careful with this. You don’t want to go overboard and annoy your visitors.

We have some simple animation you can easily add to your menu button to help it really stand out! Here’s what they look like:

Here’s how to add the Call to Action Attention Grabbers:

  1. Add either of the CSS classes to your menu CSS Field (with a space after the previous class we added above)
    1. Wiggle: divi-life-wiggle
    2. Breathing: divi-life-breathing
  2. Next, add the CSS code below to your Divi Theme Options (or your child thee style.css file).
.divi-life-wiggle {
	box-shadow: 0 0 1px transparent;
    -moz-osx-font-smoothing: grayscale;
    backface-visibility: hidden;
    -o-backface-visibility: hidden;
    -ms-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -o-transform: translateZ(0);
    -ms-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -webkit-transform: translateZ(0);
    animation-name: wiggle;
    -o-animation-name: wiggle;
    -ms-animation-name: wiggle;
    -moz-animation-name: wiggle;
    -webkit-animation-name: wiggle;
    animation-duration: 5s;
    -o-animation-duration: 5s;
    -ms-animation-duration: 5s;
    -moz-animation-duration: 5s;
    -webkit-animation-duration: 5s;
    animation-timing-function: linear;
    -o-animation-timing-function: linear;
    -ms-animation-timing-function: linear;
    -moz-animation-timing-function: linear;
    -webkit-animation-timing-function: linear;
    animation-iteration-count: infinite;
    -o-animation-iteration-count: infinite;
    -ms-animation-iteration-count: infinite;
    -moz-animation-iteration-count: infinite;
    -webkit-animation-iteration-count: infinite;
    animation-play-state: running;
    -o-animation-play-state: running;
    -ms-animation-play-state: running;
    -moz-animation-play-state: running;
    -webkit-animation-play-state: running;
}

.divi-life-breathing {
	-webkit-animation:divi-bar-breathing 7s ease-out infinite normal;
	animation:divi-bar-breathing 7s ease-out infinite normal
}


@keyframes wiggle{2%{-webkit-transform:translateX(3px) rotate(2deg);transform:translateX(3px) rotate(2deg)}4%{-webkit-transform:translateX(-3px) rotate(-2deg);transform:translateX(-3px) rotate(-2deg)}6%{-webkit-transform:translateX(3px) rotate(2deg);transform:translateX(3px) rotate(2deg)}8%{-webkit-transform:translateX(-3px) rotate(-2deg);transform:translateX(-3px) rotate(-2deg)}10%{-webkit-transform:translateX(2px) rotate(1deg);transform:translateX(2px) rotate(1deg)}12%{-webkit-transform:translateX(-2px) rotate(-1deg);transform:translateX(-2px) rotate(-1deg)}14%{-webkit-transform:translateX(2px) rotate(1deg);transform:translateX(2px) rotate(1deg)}16%{-webkit-transform:translateX(-2px) rotate(-1deg);transform:translateX(-2px) rotate(-1deg)}18%{-webkit-transform:translateX(1px) rotate(0);transform:translateX(1px) rotate(0)}20%{-webkit-transform:translateX(-1px) rotate(0);transform:translateX(-1px) rotate(0)}}.divi-bar-breathing{-webkit-animation:divi-bar-breathing 7s ease-out infinite normal;animation:divi-bar-breathing 7s ease-out infinite normal}@-webkit-keyframes divi-bar-breathing{0%{-webkit-transform:scale(0.9);transform:scale(0.9)}25%{-webkit-transform:scale(1);transform:scale(1)}60%{-webkit-transform:scale(0.9);transform:scale(0.9)}100%{-webkit-transform:scale(0.9);transform:scale(0.9)}}@keyframes divi-bar-breathing{0%{-webkit-transform:scale(0.9);-ms-transform:scale(0.9);transform:scale(0.9)}25%{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}60%{-webkit-transform:scale(0.9);-ms-transform:scale(0.9);transform:scale(0.9)}100%{-webkit-transform:scale(0.9);-ms-transform:scale(0.9);transform:scale(0.9)}}

That’s it! Let us know what you think in the comments, and don’t forget to subscribe below to get access to all of our Divi Tutorials, Freebies, and more.

53 Comments

  1. Avatar

    Tim, I may have missed it in your live stream but what is the purpose of the “@keyframes wiggle…. ” section at the bottom of the code? Isn’t the wiggle covered in the .divi-life-wiggle{ code at the beginning?

    Reply
    • Avatar

      Hey Mickey! So the keyframes is necessary for the animations. It’s essentially what creates and defines what the animation looks like (What’s happening, the position, etc). And then the rest of the CSS is actually adding the animation to the specific CSS class and defining how quickly it should run, etc.

      Reply
  2. Avatar

    It also works on other Divi elements. : )

    Reply
  3. Avatar

    Fabulous, you solved my problem. However, is it possible to have have a different color then the other buttons, like for example when your on the home the color of the home button should be different!?

    But, I am already saved by this little tutorial. Thank you sir for sharing.

    Reply
    • Avatar

      absolutely! This should do the trick:

      .home .divi-life-cta-menu a {
      background-color: #000;
      }

      Reply
  4. Avatar

    Hi! It looks like the button color changes to black when scrolling down. How do you ensure that the fixed menu text color for the CTA button stays white?

    Reply
    • Avatar

      Try changing the beginning of the CSS to this:

      .divi-life-cta-menu a, .et-fixed-header .divi-life-cta-menu a {

      Reply
      • Avatar

        Hi, I’ve tried this but the text still changes on scroll.

        Reply
  5. Avatar

    Thanks for the animation. The button did not work for me, for some reason, bit dissapointed, not sure how to fix it…

    Reply
    • Avatar

      Hmm sorry to hear that. Without seeing the link there’s not much I can do to help unfortunately. 🙁

      Reply
  6. Avatar

    Hi Tim,

    I followed your instructions but my button text color goes from white (the color I set in the CSS) to dark grey. I can’t get it to stay the color I picked. Any idea why that would be?

    Thanks for the tutorial.

    Reply
    • Avatar

      Try changing the CSS to this:

      .divi-life-cta-menu a, .et-fixed-header .divi-life-cta-menu a {

      Reply
  7. Avatar

    This is great thank you for the tips! Having issues with the padding and the button being offset in regards to height in my menu bar. Any thoughts?

    Reply
    • Avatar

      Hmm it’s hard to say without seeing it, but it’s likely something that can be easily adjusted with CSS. Try adjusting the margin-top of the button 🙂

      Reply
      • Avatar

        I think that the size of the button get smaller or bigger when at the same time, I minimize or maximize the logo or the letters. Is it possible to set the size of the top and bottom?
        Thank you!

        Reply
  8. Avatar

    Super helpful, thanks!

    Do you know how I can keep the button letters white? Every time I scroll down, it returns to the basic navbar color.

    Reply
    • Avatar

      Try changing the CSS to this:

      .divi-life-cta-menu a, .et-fixed-header .divi-life-cta-menu a {

      Reply
  9. Avatar

    I love being able to add animation, it really steals the show! Thank you

    I’m wondering if there is a way to color the “cta” text white overriding the text setting in the menu module?

    here is what I have so far votecathryn.com

    I love Divilife!

    Reply
  10. Avatar

    I just found this wonderful tutorial on adding a button to a menu, but the code is missing from the post. Could you please provide me the code, including the breath and wiggle codes as they are also missing from the post. I appreciate it, this information was great. Thinking about buying the all-access product soon.

    Reply
    • Avatar

      Hey Scott, sorry about that! It’s now fixed. We had a glitch that removed code from code snippets from a bunch of our tutorials.

      Reply
  11. Avatar

    I have successfully added the button with the wiggle animation. I am so happy. it is looking great. If you want, check out the button on my website. I have searched for this and finally found it here. Thank you for the great article.

    Reply
  12. Avatar

    Hey Tim! Thanks for a great tutorial! There is one problem that isn’t working. I have a fixed menu and there is a lot of excess top and bottom padding. No matter if I change the pixels, the padding stays the same. Here’s the site

    https://blinkprettyla.com

    Reply
    • Avatar

      It looks good to me, were you able to get it figured out?

      Reply
  13. Avatar

    Had Spacing issues and wanted a stroke around the button with filled with the same color as the menu and managed to achieve all that. Can you tell me how to reverse button background and text colors on hover? You help is much appreciated

    Mt dev site is here https://dev2.inkonpaperprinting.com/

    Thanks in advance

    Reply
    • Avatar

      I had the same issue as Howard here, is there a way to fix this?

      Reply
  14. Avatar

    Thx so much. How do I make the button go to a specific page on the site?

    Reply
    • Avatar

      This tutorial uses a menu item from a WordPress menu. So you adjust the page with WP’s menu system.

      Reply
  15. Avatar

    How do you stop the button text from going transparent when you scroll down the page? I would like the button text to stay visible as you scroll down the page.

    Reply
    • Avatar

      Try changing the CSS to this:

      #main-header .divi-life-cta-menu a, #main-header.et-fixed-header .divi-life-cta-menu a {
      background-color: #44ceb0;
      padding: 15px 25px !important;
      border-radius: 25px;
      text-transform: uppercase;
      color: #fff !important;
      text-align: center;
      }

      That should keep it the same for both the default and fixed header.

      Reply
  16. Avatar

    Thanks, I tried your code works like a charm, on both default & fixed header

    Reply
  17. Avatar

    Hi,
    Excellent! Your code works on fixed header, on hover and on active item! Wonderful!

    Reply
  18. Avatar

    This was awesome information…. works like a charm.. thanks so much.

    Reply
  19. Avatar

    very helpful! I was wondering how I could insert a link to my email instead of a webpage?

    Reply
    • Avatar

      I have found that answer 😉 thanks again!

      Reply
  20. Avatar

    Awesome, you just have a small error in your text:
    Then, open up the menu item you’d like to transform into a button, and paste the CSS class divi-life-cta-button as shown in the screenshot below:

    Should say menu instead of button.

    Reply
  21. Avatar

    Hi Tim,

    Thank you so much for the menu button css, it is truly awesome. The only issue I am having and cannot seem to fix is when I hover over the button in mobile view (from the hamburger drop-down), the resulting (hover) opacity makes the button almost completely invisible against the white background. Is there a fix for this?

    Reply
  22. Avatar

    Hi Tim
    I’ve set in the class and the code to my menu-button. However the text does not change color. It inherits the color set in the design in the menu modul. I have put in !important and also tried with the code from one of you answers above:

    .divi-life-cta-menu a, .et-fixed-header .divi-life-cta-menu a {

    The button text is still not changing to white #

    Thanks in advance
    /Dorthe

    Reply
  23. Avatar

    I have solved the problem by doing this:

    If you set an CSS ID to your menu modul (advance tab) eg “menu-cta” then you can add that ID to your css code like this:

    #menu-cta .menu-cta-button a {

    background-color: #008491; /* Change button background color here */
    color: #fff !important; /* Change button text color here */
    }

    And the rest of the css code of course 🙂

    /D

    Reply
  24. Avatar

    Be sure to set a negative top margin of 15 if you want it to be inline with the other menu items.

    Reply
  25. Avatar

    Hello,

    I’ve got this button working nicely for my client’s website, however, it’s not working correctly for the fixed header.

    My default ‘active link’ colour in the navigation is the same size as the ‘button’ background, and when I’m on the page belonging to that link, the text colour reverts back to that active link colour on scroll, becoming invisible.

    I’m using this CSS:

    #main-header .divi-life-cta-menu a, #main-header.et-fixed-header .divi-life-cta-menu a {
    background-color: #94ce00;
    padding: 15px 25px !important;
    border-radius: 25px;
    text-transform: uppercase;
    color: #fff !important;
    text-align: center;
    }

    And this is a link to the page on the development site where I’m having the problem: https://bethr25.sg-host.com/contact/

    I’d be grateful for any advice on how to make the text stay white on scroll, even when it’s the active link!

    Reply
  26. Avatar

    Great tutorial.
    Is it possible to add a little arrow in the button, when I hover over it with my coursor?

    So this would be added after the text: >

    Thanks.

    Reply
    • Avatar

      That can be done with CSS using the :after and :hover pseudo selectors

      Reply
  27. Avatar

    Thank you for this! I found 3 other use cases for what I was trying to do and none of them worked! I wish I had found yours first!! ♥

    Reply
    • Avatar

      That’s great! But sorry you didn’t find ours first!

      Reply
  28. Avatar

    I have installed the same code on two different DIVI sites, and for some reason on the second site that I tried it, it doesn’t work! The first site worked instantly, no issues.
    This second site does not work.
    Any suggestions: https://www.arboldevidacorcovado.com/

    Reply
    • Avatar

      Make sure you clear cache, and don’t have any optimization/performance plugins that are blocking Javascript from loading. If you do, make sure to exclude the carrousel code from being optimized.

      Reply
  29. Avatar

    I’ve tried this but it’s not showing. I was trying to apply it to the STORE link in the menu:

    https://www.zaphielle.com/

    Any ideas why it’s not working?

    Reply
    • Avatar

      It looks like it’s working now!

      Reply

Submit a Comment

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