Monday , February 3 2025

Zooming in and out of an image/button/link when hovering over an element

You need to use the transform property and set it to scale(1.1) to increase it and scale(0.9) to decrease it. When hovering over an image/button/link with the class button, it will increase by 10% or decrease by 10%.

Increase image/button/link – CSS:

.button:hover {
  -webkit-transform: scale(1.1);
  -ms-transform: scale(1.1);
  transform: scale(1.1);
}

Decrease the size of the image/buttons/links – CSS:

.button:hover {
  -webkit-transform: scale(0.9);
  -ms-transform: scale(0.9);
  transform: scale(0.9);
}

If you want to change the size smoothly, then for .button and for .button:hover add:

transition: 2s;

where 2s can be changed to 1 sec, 3 sec etc.

About iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

Check Also

Css styles for WordPress admin in functions.php

If you need to add individual styles, and they are only a couple of lines, …

Leave a Reply

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