fit image in a smaller div without stretching it
html:
make a div with class="imageholder" and inside it put an img control.
css:
.imageholder {
width: 512px;
height: 512px;
overflow: hidden;
}
Written by ali mousavi
Related protips
4 Responses
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/12803/livi.png)
I don't see how you code is resizing image? It's just cropping an image.
over 1 year ago
·
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44093/d42a7264714dee5006b9c99d2567a320.jpeg)
agreed, that's not resizing
over 1 year ago
·
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/33777/10684317_693196797432883_114022871_n.jpg)
@dpashkevich I changed the title.
over 1 year ago
·
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44093/d42a7264714dee5006b9c99d2567a320.jpeg)
@musyo people just call it crop :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#