Reputation: 1345
I've an gallery with different size of images. Is there any solution to crop them during display? I've tried to set style height: xxxpx but it looks awful (with width too). This images display from another sites, so I cant just download them and crop :(
Upvotes: 1
Views: 554
Reputation: 2474
You can crop an image by putting it inside an
overflow: hidden;
div.
Heres a JSFiddle example Cropped Image, of course you wil probably want to use same javascript to centre/position the image and not simple setup magin numbers in the example I've done, but still it shows how to crop the image.
Upvotes: 3
Reputation: 17896
You could also just set the width to a pixel measure in the html or the css and leave the height, or vice-versa, depending on whether you need them the same height or same width. Then they will be reduced but not distorted... obviously, if you need to crop to a set height and width, this won't work, but it will give you columns or rows that match in width or height.
Upvotes: 0
Reputation: 3224
Here is a jQuery plug-in that should do the trick: http://odyniec.net/projects/imgareaselect/
Upvotes: 0