Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re size different images without distortion

All the images have one thing in common; they are all 300 or 600 pixels wide. But the heights vary from around 300-900 pixels. Now I need a small group of the images which will be used to suggest other images for the user. These will only be around 100x200 pixels(might change). My previous attempt has made the images shrink into the 100x200 aspect ratio. I need it to overlap, but the excess is hidden.

like image 240
Harry Avatar asked Dec 02 '25 05:12

Harry


2 Answers

Try something like this http://dabblet.com/gist/2769112

The CSS you will need is simply

.img-container {
    width: 200px; /* whatever set width */
    height: 100px;
    display: inline-block; /* or you could float them */
    overflow: hidden;
}
.img-container img {
    width: 100%;
}
like image 98
Ana Avatar answered Dec 03 '25 20:12

Ana


Put the images in a wrapping element, such as a DIV, with a defined height and width and use overflow:hidden.

like image 41
Diodeus - James MacFarlane Avatar answered Dec 03 '25 20:12

Diodeus - James MacFarlane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!