treehouse : what would you like to learn today?
Web Design Web Development iOS Development

cropping images with CSS

  • Hey guys and Gals. I was wondering if anyone new of a way to crop or clip images to a specified size (ie. 100px x 100px). I have images that are being loaded from a database (this is supposed to be a photo gallery). Some images are 100px 150px but I really want the thumbnails to be the same size. Is this possible? I know there are ways to clip background images, but these images will be added dynamically and I don't want to have distorted thumbnails.

    Thanks for help/advice.
    Mark
  • You could wrap the images in container elements (DIV, LI, etc), set a fixed height and width, and then set overflow:hidden.
  • PHP is your best option http://phpthumb.sourceforge.net/
  • thanks for your help. I will be giving both a try. Keep you posted.