Forum Moderators: open

Message Too Old, No Replies

Fluid centering with DIV's?

Trying to get out of the table habit

         

dhdweb

8:08 pm on Sep 5, 2002 (gmt 0)

10+ Year Member



You all know how easy it is to center a table and have it fluid with window size, right?

This may be a dumb question but, How do I do this with a DIV?

No matter the window size I want it centered!

Thanks in advance,
dhdweb

mivox

3:52 am on Sep 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any luck yet? I must admit to being stumped... it may well be impossible with current borwsers and standards. :(

dhdweb

9:08 pm on Sep 9, 2002 (gmt 0)

10+ Year Member



MCookie's solution works great untill you want to add more DIV's that follow the centered DIV.

I ended up resorting to left aligned solution, and then added a color fade to right side to use the empty space on higher resolutions.

Why can't CSS have <div style="position:center">?

Maybe an oversight?

Maybe in the next version?

Who knows! :)

tedster

11:12 pm on Sep 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've given up on this for now. Tables are still my friend for centering an entire layout - which I agree looks much better for many sites than a flush left orientation.

I believe that setting margin-left:auto and margin-right:auto (along with setting a width for the div) "should" do the trick in a browser that supports standards perfectly. But that's certainly not what we have at present.

Even instructions as simple as margin-left:20% margin-right:20% do not result in centered content on Explorer. The right margin is always bigger than the left margin. Trying to set the padding is even worse.

antidote

3:41 am on Sep 10, 2002 (gmt 0)

10+ Year Member



I kind of skimmed over the previous posts. Was this said?

body {
text-align: center
}
div.body {
margin: auto:
text-align: left;
}

I don't even text NN4.XX anymore as it is such as small % of my visitors.

This 34 message thread spans 2 pages: 34