Adding Zoom Effect on Hover to Post Thumbnail on Divi Blog Module
Tags: divi, wordpress
Published: 2023-09-12 05:56:39

Divi comes with a built-in module called Blog dedicated to displaying content on your WordPress website. The elements you can display on your content feed include post thumbnail/featured image, post title, and post meta (author, date, and so on). Several built-in styling options are available to style up each element. Unfortunately, there is no built-in option to add a zoom effect -- or other effects -- on hover.

In this post, I will show you how to add a zoom effect to the post thumbnail on Divi blog module.

## Steps to Add Zoom Effect on Hover to Post Thumbnail on Divi Blog Module

Although Divi has no built-in option to add a hover effect to the post thumbnail on the Blog module, you can achieve it via custom CSS. In Divi itself, you can add custom CSS to a certain module element directly without defining the selector. You can access the custom CSS feature by going to the **Advanced** tab on the module settings panel. Simply open the **Custom CSS** block.


![Custom CSS block in Divi module settings panel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3perpnr06l7czw4pfvu.jpg)

The text editor fields available on the Custom CSS block varied, depending on the module. On the Blog module itself, you can find a **Featured Image** field. As you can guess, you can use the editor field to add custom CSS to the post thumbnail. You can actually add a hover effect directly to the post thumbnail via this field by switching to the hover mode (by clicking the cursor icon). However, the result is a bit weird as you can see on the animated GIF below.


![Wrong hover effect on Divi Blog module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ak9964ptl2z8422of6zp.gif)

There is a better way to add hover effect to the post thumbnail on the Divi blog module.

The steps I will below involve selector declaration. You can read my previous post to learn more about how to [use CSS selector on Divi](https://dev.to/sunawang/using-custom-class-selector-in-divi-1gnk).

First, add the Blog module and set the layout to Grid. Make sure to enable featured image on the module. Style up the blog per your preference. Once done, add a Code module and paste the following snippet:

```
<style>
.et_pb_post .entry-featured-image-url {
	margin: 0;
}
.et_pb_blog_0 .et_pb_image_container {
	overflow: hidden;
}
.et_pb_blog_0 .et_pb_image_container img {
	transition: all 0.95s ease;
	-moz-transition: all 0.95s ease;
	-webkit-transition: all 0.95s ease;
}
.et_pb_blog_0 .et_pb_post:hover img {
	transform: scale(1.15) rotate(1deg);
	-moz-transform: scale(1.15) rotate(1deg);
	-webkit-transform: scale(1.15) rotate(1deg);
}
</style>

```
The above snippet will result in the following hover effect.


![Proper hover effect on Divi Blog module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/edvrpexfdz8gz0pf06b8.gif)

You can change the hover effect by editing the `transform: scale(1.15) rotate(1deg);` line on the above snippet. You can refer to [this page](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) to learn more about CSS transform.

If you apply the CSS snippet above using the Code module, the effect will only apply on the current page only. If you want to apply it to all Blog modules on your website, you can place the snippet to [Divi](https://www.wppagebuilders.com/divi-builder/) Theme Options.

### Code Explanation

First, the code adjusts the image spacing using the `margin` property. Next, it keeps the zoomed image in the frame using the `overflow` property. The `transform` property is used to add the zoom effect on hover, while the `transition` property adds a smooth transition for the zoom effect.