Simple Image Hover Effects in HTML & CSS

CSS image hover effects

In this article, you will learn how to create Image Hover Effects using only HTML and CSS. I have already shared an image hover tutorial using JavaScript. We use different types of hover effects in the image. CSS hover is used between different image galleries and sliders.

Cool image hover effects are created using HTML and CSS. 3 images have been used here. Under normal conditions, the images will be slightly blurred and slightly rotated along the y axis.

First I added the images with the help of HTML then I designed the images using some amount of CSS. Opacity: Images are blurred using 0.4 and images are rotated slightly to 3D using rotateY (30deg).

CSS Image Hover Effect

Below is a preview that will help you to know how this simple image hover zoom effect works in CSS. Here you will find the required source code.

See the Pen Cool cards animation by Shantanu Jana (@shantanu-jana) on CodePen.


As you can see, three images have been used. These images are then bent at a certain angle of 30 degrees. With this, opacity: 0.4 has been used in the images. When you click on the images or move the mouse, the opacity will be 1. 

As a result, we can see the images again. With this, the images have been rotated along the Y-axis using transform. When you hover over the images, the value of this rotation will be zero and we will see the images in normal conditions.


How To Create An Image Hover Effect in CSS

Now if you want to create this CSS hover effects image then first you have to create HTML and CSS files. Here I have provided the source code as required and show you how to add those codes to your file. 

I did not share the step-by-step tutorial army here. Because the code used here is very simple you can easily understand it. If there is any difficulty then you can definitely let me know by commenting.


HTML Code (index.html)

The following code is the HTML code with which the images have been added. Here first an area is created then 3 images are added. Copy the following code and add it to your HTML file.


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--CSS files-->
  <link rel="stylesheet" href="style.css">
 
</head>
<body>
  <div class="images_box">
    <!--images-->
    <img src="https://images.pexels.com/photos/4902634/pexels-photo-4902634.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
    <img src="https://images.pexels.com/photos/3489376/pexels-photo-3489376.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
    <img src="https://images.pexels.com/photos/2833348/pexels-photo-2833348.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
  </div>
</body>
</html>

CSS Code (style.css)

Images are designed with the following CSS code. Then the hover effect is added to the image. Copy the following code and add it to your CSS file.


/* basic design of the webpage */
* {
    margin: 0;
    padding: 0;
  }
 
  body {
    display:flex;
    justify-content:center;
    align-items:center;
    height: 100vh;
    background-color: black;
  }
  /* image area */
  .images_box {
    display:flex;
    justify-content:center;
    align-items:center;
    max-width: 600px;
    max-height: 400px;
    gap: 3rem;
  }
   /* design the images */
  img {
    width: 40%;
    height: 100%;
    border-radius: 10px;
    transform-origin:center;
    transform:perspective(500px) rotateY(30deg);
    -webkit-box-reflect: below 3px linear-gradient(transparent, transparent, rgba(255,255,255,0.3));
    transition: 0.6s;
  }
 
  .images_box img {
    opacity: 0.4;
  }
  /* image hover effect */
  .images_box img:hover {
    opacity: 1;
    transform: perspective(800px);
  }


Hope you use these codes to create this Simple Image Hover Effects. If there is any problem then you can definitely let me know by commenting. All the source code to enhance this CSS Image Hover Effects is in the button below.