View Full Version : Centering Non-Fixed Width Divs
12-19-2006, 08:40 PM
Hey everyone, I've been running off of this template (http://gabrielloeb.com) for a while now, and I'm getting to be ready for a change. I've perused many CSS articles looking for an answer to this question, but I can only seem to find solutions for fixed with divs. My question is, how can I go about centering a non-fixed width div? The reason I'm hoping to know is that I would like to be able to center the content without posting ONLY vertical or ONLY horizontal images. I'd also like to be able to go somewhere in between. Any suggestions?
Thanks so much,
12-20-2006, 06:27 AM
use margins set to "auto"
read here: http://bluerobot.com/web/css/center1.html
12-20-2006, 06:01 PM
Thanks Connie, but unfortunately that only applies to fixed-width divs, making it somewhat useless for those who would like to display divs with variable widths (for varied width images).
I have tested this myself, using the same code without a width set and then with.
12-22-2006, 05:29 AM
I'm really hoping I won't have to resort to <center>. Any help you can give would be appreciated.
12-22-2006, 07:22 AM
you have the Pixelpost tag <IMAGE_WIDTH> in your template.
Why don't you use that to fix the width of your div? (in template, not in css file):
<div id="content" style="width:<IMAGE_WIDTH>">
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.