View Full Version : PHP Photo Album Center Images Within Div

04-15-2010, 12:26 PM
1) Script Title: PHP Photo Album 2.11

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

3) Describe problem: I have the script working well here http://www.rjt-online.com/2010%20Website/photos_live.php.

However, if the photo is Portrait and the correct width, it fits the containter div nicely (photodiv).

However if the photo is landscape or larger portrait, the image is cropped.

I dont want the images to be shrunk by x% as come images are landscape and others are portrait.

How can I modify my CSS so each image, regardless of the size and regardless of it being portrait/lanscape, fits centrally in the photodiv with equal overflow (hidden) on each side?

If an images is 500px wide and the photodiv is 200px wide, I want somehow to automatically calculate per image the left and right margins. In this case it would calculate that the left margin needs to be -150px and the righht maring needs to be 150px, therefore the center of the image should be in the center of the photodiv regardless of the size of image.

Any help would be appreciated.


04-15-2010, 10:54 PM
"Photodiv" is wrapped around each thumbnail imag actuallye, and the thumbnail image itself isn't cropped, only resized per ddphpalbum.css (ie: 200px by 160px). Each image is fully viewable, albeit distorted in some cases. Regardless though, if you're asking how to not resize each thumbnail image, but instead center it within the container, it's certainly possible but somewhat complicated to do.

04-19-2010, 09:55 AM
Do you know how it can be done?

I have tried all sorts but I have had no success.

I am using the same CSS for the images on the right (bottom) of this page http://www.rjt-online.com/2010%20Website/home_new.php , and they are centered correctly as I would like them to be on my photo page.

Thanks in advance.