Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / October 2007



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Summercool - 30 Oct 2007 07:42 GMT
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?
Ben C - 30 Oct 2007 09:13 GMT
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.