{"id":82,"date":"2026-10-18T17:53:18","date_gmt":"2026-10-18T17:53:18","guid":{"rendered":"https:\/\/refracttools.com\/blog\/?p=82"},"modified":"2026-10-18T17:53:18","modified_gmt":"2026-10-18T17:53:18","slug":"divi-button-hover-effects","status":"publish","type":"post","link":"https:\/\/refracttools.com\/blog\/css-techniques\/divi-button-hover-effects\/","title":{"rendered":"Button hover effects in Divi 5 (without fighting Divi)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To add a custom button hover effect in Divi 5, open the Button module&#8217;s <strong>Advanced \u203a Custom CSS \u203a Free-Form CSS<\/strong> and paste CSS that starts with the <code>selector<\/code> keyword. Divi swaps <code>selector<\/code> for that module, so the effect applies to this one button. Leave the module&#8217;s <strong>Use Custom Styles For Button<\/strong> option off, or Divi&#8217;s own button styles can override the effect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Divi&#8217;s Button module handles colours, borders and simple hover changes on its own. Effects like a light sweeping across the button, a fill sliding in or a glowing animated border need a little CSS. This guide shows how to add them in Divi 5, with a Divi 4 method too.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-takeaways is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Key takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Divi 5: paste CSS beginning with <code>selector<\/code> into Advanced \u203a Custom CSS \u203a Free-Form CSS on the Button module.<\/li>\n\n\n<li>Divi 4: add a CSS class to the module and paste the CSS into Divi \u203a Theme Options \u203a General \u203a Custom CSS.<\/li>\n\n\n<li>Keep &#8220;Use Custom Styles For Button&#8221; off so Divi&#8217;s button styles don&#8217;t fight the effect.<\/li>\n\n\n<li>Run the effect on <code>:focus-visible<\/code> too, and switch motion off for people who prefer reduced motion.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Which hover effects need CSS?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Divi&#8217;s built-in hover options change properties such as colour, border and shadow. Effects that use a pseudo-element, a sliding layer or a keyframe animation need custom CSS. These are the ones Refract&#8217;s <a href=\"https:\/\/refracttools.com\/button-hover-effects\/\">button hover effects generator<\/a> writes for Divi:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Effect<\/th><th>What happens on hover<\/th><\/tr><\/thead><tbody><tr><td>Shine sweep<\/td><td>A soft band of light slides across the button<\/td><\/tr><tr><td>Fill slide<\/td><td>A second colour slides in from one side<\/td><\/tr><tr><td>Animated gradient border<\/td><td>A gradient border rotates around the button<\/td><\/tr><tr><td>Glow pulse<\/td><td>A soft glow breathes around the edge<\/td><\/tr><tr><td>3D press<\/td><td>The button presses down onto a hard shadow<\/td><\/tr><tr><td>Underline grow<\/td><td>A line grows under the label<\/td><\/tr><tr><td>Gradient shift<\/td><td>The background gradient slides across<\/td><\/tr><tr><td>Glass<\/td><td>A frosted, translucent button for use over images<\/td><\/tr><tr><td>Neon<\/td><td>A bright outline and glow<\/td><\/tr><tr><td>Lift<\/td><td>The button rises with a deeper shadow<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Add a hover effect in Divi 5<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the settings for the <strong>Button<\/strong> module.<\/li>\n\n\n<li>In the Design tab, check that <strong>Use Custom Styles For Button<\/strong> is off.<\/li>\n\n\n<li>Go to <strong>Advanced \u203a Custom CSS<\/strong> and choose the <strong>Free-Form CSS<\/strong> tab.<\/li>\n\n\n<li>Paste the code and save the page.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This is the shine sweep as the generator writes it for Divi 5, shortened slightly here (the generator also sets the font size, weight and alignment):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>selector.et_pb_button,\nselector .et_pb_button {\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n  background: #2f4bff;\n  color: #ffffff;\n  border: 0;\n  border-radius: 12px;\n  padding: 13px 24px;\n}\n\nselector.et_pb_button::before,\nselector .et_pb_button::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);\n  transform: translateX(-120%);\n  transition: transform 0.5s cubic-bezier(.2,.8,.2,1);\n  pointer-events: none;\n}\n\nselector.et_pb_button:hover::before,\nselector .et_pb_button:hover::before,\nselector.et_pb_button:focus-visible::before,\nselector .et_pb_button:focus-visible::before {\n  transform: translateX(120%);\n}\n\n@media (prefers-reduced-motion: reduce) {\n  selector.et_pb_button::before,\n  selector .et_pb_button::before {\n    transition: none;\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each rule lists two selectors, <code>selector.et_pb_button<\/code> and <code>selector .et_pb_button<\/code>, so it reaches the clickable button whether Divi applies <code>selector<\/code> to the button itself or to the module around it. The shine uses <code>::before<\/code>, which leaves Divi&#8217;s <code>::after<\/code> button icon free to work as normal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Divi&#8217;s help centre describes Free-Form CSS and the <code>selector<\/code> keyword in its guide to <a href=\"https:\/\/help.elegantthemes.com\/en\/articles\/13480630-where-to-add-custom-css-code-in-divi-5\" rel=\"noopener\" target=\"_blank\">where to add custom CSS in Divi 5<\/a>.<\/p>\n\n\n<aside class=\"tool-card tool-card--inline\"><span class=\"swatch\" style=\"background:linear-gradient(120deg,#2f4bff 40%,#9fb0ff 50%,#2f4bff 60%)\" aria-hidden=\"true\"><\/span><div class=\"tool-card__body\"><p class=\"tool-card__eyebrow\">Free tool<\/p><p class=\"tool-card__name\">Button hover effects generator<\/p><p class=\"tool-card__blurb\">Shine, fill, glow and animated-border button effects for any page builder.<\/p><\/div><a class=\"btn primary\" href=\"https:\/\/refracttools.com\/button-hover-effects\/\">Try it free <span aria-hidden=\"true\">\u2192<\/span><\/a><\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Add a hover effect in Divi 4<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Divi 4&#8217;s module CSS boxes only accept declarations, not full rules with <code>:hover<\/code> and <code>::before<\/code>, so for these effects use a class instead:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Button module and go to <strong>Advanced \u203a CSS ID &amp; Classes \u203a CSS Class<\/strong>. Type <code>rf-button<\/code>.<\/li>\n\n\n<li>Paste the CSS into <strong>Divi \u203a Theme Options \u203a General \u203a Custom CSS<\/strong>. The rules start with <code>.rf-button.et_pb_button<\/code>.<\/li>\n\n\n<li>Save, then exit the Visual Builder to check the effect on the live page.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Why isn&#8217;t the hover effect working?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Problem<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Divi&#8217;s own hover colour or border appears instead<\/td><td>Turn off Use Custom Styles For Button, or untick Include colours in the generator and set colours in Divi<\/td><\/tr><tr><td>Nothing changes in the Visual Builder<\/td><td>Save and view the live page; some effects only show outside the builder<\/td><\/tr><tr><td>The effect applies to every button<\/td><td>You pasted the Divi 4 CSS without adding the class, or used the class on several modules<\/td><\/tr><tr><td>The button icon has disappeared<\/td><td>Use an effect that draws on <code>::before<\/code>, as the generator does for Divi<\/td><\/tr><tr><td>Old styles stay after changes<\/td><td>Clear Divi&#8217;s static CSS and your caching plugin, then hard refresh<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Keep the effect accessible<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Keyboard users<\/strong> never hover, so pair <code>:hover<\/code> with <code>:focus-visible<\/code>. Every effect from the generator does this.<\/li>\n\n\n<li><strong>Reduced motion<\/strong>: some people get dizzy from movement. Wrap animations in a <code>prefers-reduced-motion<\/code> check so they switch off when requested.<\/li>\n\n\n<li><strong>Touch screens<\/strong> have no hover, so the effect is a bonus. Make sure the button reads clearly as a button without it.<\/li>\n\n\n<li><strong>Contrast<\/strong>: if the effect changes the background, check the label still passes on both colours with the <a href=\"https:\/\/refracttools.com\/contrast-checker\/\">contrast checker<\/a>.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group is-style-refract-callout is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Tip:<\/strong> Effects that animate <code>transform<\/code> and <code>opacity<\/code> stay smooth because the browser can hand them to the graphics hardware. Avoid hover effects that animate width, height or padding, which force the page to re-lay out on every frame.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Make your own<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open the <a href=\"https:\/\/refracttools.com\/button-hover-effects\/\">button hover effects generator<\/a>, hover over the ten effects, then set your button colour, text colour, radius and speed. Choose <strong>Divi 5<\/strong> or <strong>Divi 4<\/strong> under <strong>Paste into<\/strong> and copy code written for the Button module, with the steps underneath. For a softer depth effect without movement, the <a href=\"https:\/\/refracttools.com\/box-shadow-generator\/\">box shadow generator<\/a> builds layered shadows you can add on hover.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Sources: <a href=\"https:\/\/help.elegantthemes.com\/en\/articles\/13480630-where-to-add-custom-css-code-in-divi-5\" rel=\"noopener\" target=\"_blank\">Elegant Themes: where to add custom CSS in Divi 5<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add shine, fill, glow and animated border hover effects to Divi buttons with a few lines of CSS. Steps for Divi 5\u2019s Free-Form CSS and Divi 4, plus the setting that stops them working.<\/p>\n","protected":false},"author":1,"featured_media":81,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_refract_tool":"button-hover-effects","footnotes":""},"categories":[8],"tags":[41,38,39,40],"class_list":["post-82","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-techniques","tag-buttons","tag-divi","tag-page-builders","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":1,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions\/120"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media\/81"}],"wp:attachment":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}