I am trying to crop images in CSS but can't get it work as I wish. Here are three pictures to understand my problem :
The following screenshot represent what the "uncropped" elements look like.
For exemple, let's say I only want to keep the part of the first image going from 20% of its height to 60% of its height.
I tried to apply the following CSS to my red rectangle :
clip-path: polygon(0% 20%, 100% 20%, 100% 60%, 0% 60%);
And the result is
Which is not good because there is still some blank space around the first image (the gray background was added for better visualization.)
The result I am trying to achieve is this
I got that by hardcoding values but this won't be possible.
Is this achievable with CSS only, and knowing the width and height of the original image ?


