HomeЛюди и блогиRelated VideosMore From: Mohit Sarangal

CSS Image size, how to fill, Avoid stretch on image css

60 ratings | 9940 views
This tutorial helps you to stop image stretching while we fix height. Stretched image problem mainly seen when we fix height of any image. So there is a solution by which we can resize image without stretching and keep aspect ratio.
Html code for embedding videos on your blog
Text Comments (14)
sandip patel (14 hours ago)
very nice. very helpful
i did the first way, and its worked. But, the second way does not work. this my code; in HTML <img src="image3.png" alt="flower" class="img-thumb"/>. in CSS i type .img-thumb{ width= atuto; height= 300px;} i think i type it all correctly, but when i execute it, nothing is happen. any solution?
it works, thanks bro, you are a livesaver.
Mohit Sarangal (4 days ago)
Please add object-fit: cover; to img-thumb class
Naveen Kolambage (11 days ago)
object-fit : cover did the job , Many thanks bro!
Sia X (22 days ago)
hello brother you can teach about disign web
Héctor Serrano Castro (1 month ago)
This is so awesome, you're superb!
Aivaras Grigonis (1 month ago)
object-fit:cover ! Saved the day :D
Moses Karunia (2 months ago)
Thank you for the object-fit:cover bro!
uzdarbis namuose (2 months ago)
working 100% thanks.
Dalitso Botha (4 months ago)
English Please!!
millennial jesus (7 months ago)
this is really really good. Thanks a lot : )
Ravi Rathi (8 months ago)
brother this code is not working in IE and edge
Thank you, man! Its what i need for.

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.