I download an image from flipkart as webp format. While imporing in my site, its height and width is large and it doesn’t fit in my border and width ratio. While reducing the width and height only half og the image is shown and the image is n same size. Is there any solution to How to set the image for specific border and size?
I tried to reduce the width to percent and vh and vw in css and adjust the height . The image is correctly shown only if i do the correct measurements, but that measurements was too large . I expect the image to fit the my border size without ovversizing
3
Answers
You can achieve it by using
object-fit
property of CSS:You need to apply object-fit property to contain to ensure the entire image fits within the container.
Reference Link: https://www.w3schools.com/css/css3_object-fit.asp
Demo code (Might be different in your case):
Let me know, if you’ve any doubts.
I usually solve this problem by following two steps.