HighDots Forums  

the only way to center a div is to fix its width?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss the only way to center a div is to fix its width? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Summercool
 
Posts: n/a

Default the only way to center a div is to fix its width? - 10-30-2007 , 01:42 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?


Reply With Quote
  #2  
Old   
Ben C
 
Posts: n/a

Default Re: the only way to center a div is to fix its width? - 10-30-2007 , 03:13 AM






On 2007-10-30, Summercool <Summercoolness (AT) gmail (DOT) com> wrote:
Quote:
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.

Quote:
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?

Quote:
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.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.