I am trying to figure out, if there is any way to resize the clipped part of the image with use of css. In the most expected version, image resized this way should keep the imposed aspect ratio.
I was playing with clip-path, trying both approaches (svg & inset()), as well as working around object-position & object-fit parameters, unfortunately I can not achieve expected result :(
Here is my actual code. I need the clipped image to fit the size of the picture element (the background of picture should be covered by the clipped image)
CASE STUDY https://i.stack.imgur.com/Vx3Md.jpg
picture {
position: relative;
display: block;
width: 100%;
height: auto;
overflow: hidden;
background: #ddd;
}
picture.ratio-3-4 {
padding-top: 133.3%;
}
picture img.clip {
position: absolute;
top: 0;
left: 0;
-webkit-clip-path: inset(0 33.7% 7.6% 0);
clip-path: inset(0 33.7% 7.6% 0);
}
<picture class="ratio-3-4">
<img src="https://images.unsplash.com/photo-1551927336-09d50efd69cd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2710&q=80" class="clip" alt="">
</picture>