Divi Tutorial – animating button backgrounds

Divi Tutorial – animating button backgrounds

Let’s learn how to make some cool CSS based button animations.

This one’s relatively easy.

Let’s start with the video:

 

 

The trick is giving the background a gradient, make it larger than double the button, and aligning the left sides.
Then, on hover, move the background so its right side will align with the right side of the button.

With some clever gradients, you can make some pretty cool effects.

Where do you get the gradient? Just click on any of the cool buttons above. haha
I added the link to the buttons.

Here’s the CSS you see in the video.

.et_pb_button.background-animation {
    display: inline-block;
    border-radius: 1px;
    border: 0px;
    padding: 10px 17px 10px 20px;
        letter-spacing: 3px;
        color: #fff;
        font-size: .75rem;
        line-height: 1;
        text-transform: uppercase;
        text-align: center;
        font-weight: 700;
    

    background-size: 250% auto;
        background: rgb(255,183,107); 
        background: -moz-linear-gradient(-45deg, rgba(255,183,107,1) 0%, rgba(255,167,61,1) 50%, rgba(255,252,249,1) 51%, rgba(255,183,107,1) 55%, rgba(255,127,4,1) 100%); 
        background: -webkit-linear-gradient(-45deg, rgba(255,183,107,1) 0%,rgba(255,167,61,1) 50%,rgba(255,252,249,1) 51%,rgba(255,183,107,1) 55%,rgba(255,127,4,1) 100%); 
        background: linear-gradient(135deg, rgba(255,183,107,1) 0%,rgba(255,167,61,1) 50%,rgba(255,252,249,1) 51%,rgba(255,183,107,1) 55%,rgba(255,127,4,1) 100%); 
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffb76b', endColorstr='#ff7f04',GradientType=1 ); 
        -webkit-transition: all 0.5s ease-in-out;
        -moz-transition: all 0.5s ease-in-out;
        -o-transition: all 0.5s ease-in-out;
        -ms-transition: all 0.5s ease-in-out;
        transition: all 0.5s ease-in-out;
}
.et_pb_button.background-animation:hover {
    background-color: transparent;
    border-radius: 1px;
    border: 0px;
    padding: 10px 17px 10px 20px;

    background-position: right center;
        -webkit-transition: all 0.5s ease-in-out;
        -moz-transition: all 0.5s ease-in-out;
        -o-transition: all 0.5s ease-in-out;
        -ms-transition: all 0.5s ease-in-out;
        transition: all 0.5s ease-in-out;
}
.et_pb_button.background-animation:after {
    display: none;
}

Note: watch the video for more explanation on which lines can be taken out, or edited. (basically the first blocks, so 2-12, 28-31 can be taken out and styled within the builder as long as you don’t touch the background settings, and 16-20 is what you swap out with your own custom gradient)

So paste that CSS here:

 

Next add the custom class to the button like this:

 

And you will be finished.

 

Please leave a comment if you have any questions!

 

Here are some other similar tuts you might enjoy




 

[sc name=”learn css”]

 

Featured Image Credit: Photo by Ashkan Forouzani on Unsplash

Get Breakdance

Breakdance is, in my opinion, the best page/site builder on the market, which is why all my tutorials use Breakdance. It's also why I have an affiliate link. You don't pay extra, but I get a little commission, so it helps support the site. Thanks!

Get ACF Pro

Another essential plugin for site building. This isn't an affiliate link, it's just for convenience.

Get WP Codebox Pro

If you'd like an easier to use, and more advanced code management plugin (instead of just editing and making files yourself) then WP codebox pro is for you. Adding php, js, and even SCSS. Pretty nice! Affiliate link below.

Blank Plugin

Sort of blank. It's made to be easy to use with the tutorials. Download and edit any way you see fit.
    Leave a Reply

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

    New tutorials

    Auto-updating Year in Footer
    Designing Beyond the Brief
    Disable Gutenberg Editor on some ACF pages
    ACF flexible content fields in Breakdance 2.4

    Got a question? ask!

    If you have any question about the content on this page, feel free to send me an email by clicking the button below.

    newsletter? sign up!

    Sign up to the newsletter for updates on tutorials, news, and offers.

    Join the cypher!

    An awesome membership program for Breakdance Builder users coupled with an inclusive, friendly community.

    Got a question?

    If you have a question about something on this page, send me an email, and hopefully I can answer, and we can solve it!