Forum Moderators: not2easy
To achieve the trimming, set for the DIV:
overflow:hidden
Set your widths as you need them for the DIV:
width:100px;height:100px
Finally, set the image as a background:
background-image:url('image.jpg');background-position:-200px -200px;
Notice the background-position:? That will move the background around inside.
If you wanted you could both resize the image somewhat, AND crop it somewhat. I assume you know how to do it, so I won't bother giving an example.
And I woudlnt' really consider a javascript which removes images, and changes them to background images in other elements then centers them to be very unobtrusive. It would create noticible differences for browsers which do not have the javascript enabled.
Hell, if you wanted to use javascript, you don't need to change the image tags to background images, you could just center the images using javascript.
[edited by: Xapti at 2:39 am (utc) on Aug. 27, 2007]
There are plenty of light-weight scripts that can do this at runtime on the server - I have one that allows me to call an image like this:
/images/myimage.jpg?thumb
and it will be resized, cached and displayed. I can send you a link to the code if you like.