In this article, we will cover a famous effect used in e-commerce websites: Zooming over images. We will see how to achieve such an effect using CSS and with the smallest amount of code possible. We will end with an interactive demo at the end. Let’s go!
The zoom effect combines two things. Making the image bigger and then hiding part of it. The idea is to keep the same area of the initial image while zooming over a portion of it. To make the image bigger we will logically use a scale transformation but for the “hiding part” we have different methods.
Using Overflow: hidden
The first and easy method is to consider overflow: hidden and to do this we need an extra container for the image so our code will look like the below:
<div class="container">
<img src="" alt="" >
</div>
Here is a demo to illustrate the idea:








