Image Zoom on Hover with CSS Transition and Overflow
Create an image zoom-on-hover effect using CSS transition on transform: scale() with overflow: hidden. A popular pattern for galleries and portfolios.
Detailed Explanation
Image Zoom on Hover
The image zoom effect smoothly scales an image larger when the user hovers over it, while a container with overflow: hidden clips the enlarged image so it stays within its boundaries.
CSS Code
.image-container {
overflow: hidden;
border-radius: 8px;
}
.image-container img {
width: 100%;
height: 100%;
object-fit: cover;
transform: scale(1);
transition: transform 0.5s ease-out;
}
.image-container:hover img {
transform: scale(1.1);
}
How It Works
- The container has
overflow: hidden, which clips any content that extends beyond its bounds - The image fills the container at
scale(1) - On hover, the image scales up to
scale(1.1)— 10% larger - The container clips the overflow, so the zoom effect stays contained
Choosing the Scale Value
scale(1.05)— subtle zoom, professional feelscale(1.1)— noticeable zoom, most commonscale(1.15)— pronounced zoom, attention-grabbingscale(1.2+)— dramatic zoom, use sparingly
Adding an Overlay
Combine the zoom with a color overlay for a gallery-style effect:
.image-container::after {
content: "";
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0);
transition: background 0.5s ease;
}
.image-container:hover::after {
background: rgba(0, 0, 0, 0.3);
}
Performance
The transform: scale() approach is GPU-accelerated because it operates on the composite layer. The browser scales the rasterized layer without re-rendering the image. This makes it much more efficient than animating width and height.
Use Case
Image zoom transitions are widely used in e-commerce product grids, photography portfolios, real estate listing galleries, blog featured images, and any content-rich grid where visual engagement encourages clicks.
Try It — CSS Transition Generator
Related Topics
CSS Scale Transform Transition for Zoom Effects
Basic Transitions
Card Hover Lift Effect with Shadow and Transform
Hover Effects
CSS Fade In Transition with Opacity
Basic Transitions
GPU-Accelerated CSS Transitions for 60fps Performance
Performance Tips
CSS Button Hover Effect with Multiple Transitions
Hover Effects