PDA

View Full Version : centering a div


mightypants
05-06-2008, 01:40 PM
I'm pretty new to all of this, but have read through most of the HTML/CSS tutorials on W3Cschools.com.

I'm trying to put the bulk of the material on a web page in a centered div. I set the div margins to auto, and width to 80%. With this setting, the div is centered, but obviously when the browser window is resized, the div changes width and text/images within move around as well. I know that I can use absolute positioning and width, but then, if I'm not mistaken, whether or not the div is centered will depend on the user's display resolution/browser window size.

How can I work around these issues? Thanks.

mightypants
05-06-2008, 02:32 PM
I just saw another thread on this topic, so nevermind. Thanks.

Jim7283
05-09-2008, 03:15 PM
What you're talking about is a fluid VS. fixed width layout. If you set widths using % or EM, the elements will stretch according to the window size. If you set widths using PX they will be a fixed pixel size regardless of the the window size. Hope that helps!