This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Stylesheets > October 2007 > the only way to center a div is to fix its width?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
the only way to center a div is to fix its width?
|
|
| Summercool 2007-10-30, 4:16 am |
| since the way we center a div in a page is usually fix a width: 600px
and then set margin left and right both "auto"...
so what if we don't know the width in advance, or want it to be
automatic? in that case, use display: table? (as someone suggested
using that will make a div "shrink to fit". is it a standard way?
coz setting a non-table div to table display is kind of weird. any
other way?
| |
|
| On 2007-10-30, Summercool <Summercoolness@XXXXXXXXXX> wrote:
> since the way we center a div in a page is usually fix a width: 600px
> and then set margin left and right both "auto"...
Correct.
> so what if we don't know the width in advance, or want it to be
> automatic? in that case, use display: table? (as someone suggested
> using that will make a div "shrink to fit". is it a standard way?
> coz setting a non-table div to table display is kind of weird.
What's weird about it?
> any other way?
Display: inline-block with text-align: center on the container. But only
works in Opera and Konqueror/Safari out of well-known browsers.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|