Last Updated: February 25, 2016
·
4.271K
· themusyo

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;
}

4 Responses
Add your response

I don't see how you code is resizing image? It's just cropping an image.

over 1 year ago ·

agreed, that's not resizing

over 1 year ago ·

@dpashkevich I changed the title.

over 1 year ago ·

@musyo people just call it crop :)

over 1 year ago ·