Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Centering an Item Re: [Solved] Centering an Item

#72793
ctbrowncoat
Member

Hey gang,

I’ve been struggling with centering an image that uses Brian Revis’ "captify" script for img captions. It’s very clean and I like it, but Captify has its own set of css attributes, which I try not to tinker with. One of those is margin: 0 and a wrapper class that floats left. I took out the latter, finding that it didn’t seem to mess anything up.

I’ve built a site for my sister-in-law, which you can see here: http://www.foxfirebernese.com

On the About page (http://www.foxfirebernese.com/about.php), I had to right-align a captified-image. I got that to work by creating a div around the image and floating the div right. Worked great. However, on the Puppies page (http://www.foxfirebernese.com/puppies.php) I have to center the puppy pic. I tried the same approach, created a div to surround the img tag. Instead of float right, I said margin-left: auto and margin-right: auto. No dice. The image kept hugging the left side of the page. I could not center the image… UNTIL I specified a width of 400px (the image’s width) on my wrapper div. (centered-photo)

My question: WHY? I really don’t want to leave a specific width on that centered-photo div. Can you guys see something that’s causing that img within the div to stay left when you remove the width specification? Use firebug and disable the width: 400px on centered-photo to see what I mean.

THANKS for any help or advice!
-Greg in CT