Smooth Image Zoom on Hover with CSS
![](https://i0.wp.com/chrisyee.ca/wp-content/uploads/2022/12/arnaud-mesureur-7EqQ1s3wIAI-unsplash-scaled.jpg?fit=2560%2C1707&ssl=1)
This simple CSS hover effect will subtly & smoothly scale an image 20% larger on hover.
HTML
<a class="box" href="https://chrisyee.ca/">
<img src="http://fpoimg.com/500x500?text=Preview" alt="FPO Image">
</a>
CSS
/* Make a square box with overflow hidden */
.box{
position: relative;
aspect-ratio: 1 / 1;
overflow: hidden;
}
/* Set image to cover entire box */
.box img{
position: absolute;
top: 0;
object-fit: cover;
object-position: center;
width: 100%;
height: 100%;
z-index: 1;
transition: transform 8s ease-out;
}
/* Scale image on hover */
.box:hover img{
transform: scale(1.2);
}