Add Semi-Transparent Background to Divi Slider Text

Written by Dan Mossop

Adding a Text Overlay in Divi

There is now an option in Divi for adding an background to the slider text which can be applied on a per-slide basis without the need for the code given in this post. To use it, go into the "Design" tab of the slide you wish to add a background to. There you'll find a "Use Text Overlay" option. Activate this and you'll be able to select the color / border radius. In the color picker, the rightmost of the two bars controls the transparency.

Adding a Semi-Transparent Background using CSS

Here's how to add a semi-transparent background to the Divi Theme's slider text using CSS. While it is now largely unnecessary thanks to the new built-in Divi option mentioned above, I'll leave this code here in case it is useful (e.g. if you want to quickly apply the affect to all sliders on the site, rather than having to apply a background on a per-slide basis).

It is responsive, just like Divi itself. To create the effect, we need to add some CSS to Divi, like so:

/* Set the semi-transparent background color */
.et_pb_slide_content,
.et_pb_slide_description > h2,
.et_pb_more_button_wrap {
	background-color: rgba(0, 0, 0, 0.5);	 
}

/* Hide the content area if empty (no title and no content) */
.et_pb_slide_description:first-child .et_pb_slide_content:empty { display:none; }

/* Add 30px of padding to the background */
.et_pb_slide_description > h2 {
	padding: 30px 30px 10px 30px !important;
	margin-left:-30px;
	margin-right:-30px;
}
.et_pb_slide_description { 
	margin-top:30px; 
	margin-bottom:-30px;
}
.et_pb_slide_description > div:first-child { padding-top: 30px !important; }
.et_pb_slide_description .et_pb_slide_content,
.et_pb_more_button_wrap
 {
	padding:0px 30px 30px 30px !important;
	margin-left:-30px;
	margin-right:-30px;
}
@media only screen and ( max-width: 479px ) { 
	.et_pb_slide_description > h2 {
		padding-bottom: 0px !important;
	}
	.et_pb_slide_description .et_pb_slide_content > p {
		padding-top: 10px !important; 
	}
	.et_pb_more_button_wrap {
		display:none;
	}
}

/* Give the background rounded corners */
.et_pb_slide_description > :first-child {
	border-top-left-radius: 15px;
	border-top-right-radius: 15px;
}
.et_pb_slide_description div:last-child {
	border-bottom-left-radius: 15px;
	border-bottom-right-radius: 15px;
}

One slight complication is that slides with no titles still show an empty box. Unfortunately there isn't a good way to do this in CSS, so we need to add JQuery to Divi to hide these empty boxes, like so:

<script>
jQuery(function($){ 
    /* Hide empty slide text */
    $('.et_pb_slide_description > .et_pb_slide_content:first-child').each(function(){
        if($.trim($(this).text()) == '' 
        && $(this).children().length == 0){
            $(this).hide(); 
        }
    });
});
</script>

Changing the Box Color / Transparency

You can change the slider color and transparency by modifying the line which reads:

background-color: rgba(0, 0, 0, 0.5);

The first three values are the red, green and blue components (0-255) and the last one is the opacity (0-1).

Include the Slider Button in the Box

If you want to place the slider button inside the semi-transparent box, you'll need to add JQuery to Divi, like so:

<script>
jQuery(function($){ $(".et_pb_more_button").wrap('<div class="et_pb_more_button_wrap"></div>'); });
</script>

Note on Vertical Centering

Note that a consequence of keeping the way Divi lays out the page is that the slide text (and background box) will not necessarily be vertically centered – because Divi puts all the slide titles at the same position. If your slides all have a similar amount of text (or all have no text), this shouldn't be a problem. At some point, I'll try and come up with a better way of handling the case where slides have different amounts of text.

Enhance Your Divi Sites with Dynamic Content

Unlock more possibilities with the Divi Dynamic Content Extended plugin, perfect for adding advanced features to your site's design. With seamless integration for ACF, Meta Box, and Pods, bring your sliders to life with intelligent data-driven content.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

72 Comments

  1. Thank you Dan! Definitely worthwhile knowing how to do this regardless. Thanks for letting us in on this great little secret :)

    Reply
    • Please disregard. We decided to go in a different direction with this page. Thank you!

      Reply
    • Thanks for letting me know and all the best with the new direction! I've updated the code to include the slider button in the semi-transparent box, in case you or anyone else needs it in the future.

      Reply
  2. Another nice thing about this is you can use it to set the height of the slider by adjusting the margin pixel count. It does need some tweaks to center on mobile view though.

    Reply
    • Hi Randall, you're right it can be used to affect the height of the slider. I've come up with another way of setting the Divi slider height should you need more precise control over the height.

      Also, I've just added a revised version of the semi-transparent background code which handles mobiles better.

      Reply
  3. Dan Can you describe in more detail how to implement such as where (style.css? page) the code goes?

    thanks

    Reply
  4. Hi Dan, thanks for the great information. For some reason this code is not working. I assume it's a simple setting I need to change, or perhaps I'm putting the code in the wrong place. Any ideas? Thanks!

    Reply
    • Hey Brian, this post details where to add the CSS to Divi. If you're still having problems, drop me a link to your page and I'll take a look.

      Reply
  5. Thank you very much! Just saved me a ton of time :D
    Works perfectly…

    Reply
  6. Hi there, thank you for this tut.
    Do you know why it also changes the slider size?
    Also how can I make it responsive? The mobile version is not centered.
    Thank you in advance.

    Reply
    • Hey Facu, I've just added an updated version of the Divi slider background box code which is more responsive and better behaved – it centers in mobiles and doesn't affect the slider height.

      Reply
  7. I've searched and searched for a solution to this very appealing affect. Thank you for sharing your knowledge on this ….

    Reply
  8. Hi Dan,
    I like this one. It is a good and usable option.
    Thanks for sharing it.

    Reply
  9. Hi Dan
    Love this one – it produces a great looking effect.
    Perfect for light text on light background.
    Thanks for sharing.

    Reply
  10. Hi Dan,

    How can you do this on specific slider?

    Thanks in advance.

    Reply
    • Hi rahi, you can apply it to a specific slider by setting a CSS Class (e.g. "yourcssclass") in that slider module's settings, then replacing ".et_pb_bg_layout_dark" in the above example with ".yourcssclass".

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

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

We may earn a commission when you visit links on our website.

Latest From Divi Booster

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Fix Divi Text Module "Regular" Font Weight Not Working

Are you encountering an issue where the font weights in Divi's Text Module don't seem to apply as expected? In particular, you might find that when you set the text module's body text font weight to "Regular", your font is actually assigned a weight of 500 instead of...

Make the Divi Gallery Module Swipeable

The Divi Gallery Module comes with a slider mode that lets you display images in a slider with clickable left/right arrows to scroll through the images. For mobile / touchscreen users, you can improve the user experience by allowing your user to swipe to navigate to...

How to Use Divi Dynamic Content in Woo Modules Product Selector

Divi's Dynamic Content is a powerful feature that lets you populate your Divi modules and theme builder templates with data pulled in various sources, such as custom fields. This allows for efficient organization and maintenance of your sites.Unfortunately, Divi's...

Random Divi Posts