You could achieve that simply by wrapping the image by a <div> and adding overflow: hidden to that element:
<div class="img-wrapper">
<img src="..." />
</div>
.img-wrapper {
display: inline-block; /* change the default display type to inline-block */
overflow: hidden; /* hide the overflow */
}
Also it’s worth noting that <img> element (like the other inline elements) sits on its baseline by default. And there would be a 4~5px gap at the bottom of the image.
That vertical gap belongs to the reserved space of descenders like: g j p q y. You could fix the alignment issue by adding vertical-align property to the image with a value other than baseline.
Additionally for a better user experience, you could add transition to the images.
Thus we’ll end up with the following:
.img-wrapper img {
transition: all .2s ease;
vertical-align: middle;
}