HighDots Forums  

Centering a Div

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Centering a Div in the Macromedia Dreamweaver forum.



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

Default Centering a Div - 10-23-2007 , 07:31 AM






Hi,
Up to now I've used
#container {
width: 920px;
margin-right: auto;
margin-left: auto;
}
along with text-align: center; in the body to center my pages.

Another method is
#container {
width: 920px;
margin-left: -460px;
position: absolute;
left: 50%;
}

What are the pros and cons of the two methods - is one of them 'best' ?


Reply With Quote
  #2  
Old   
Loco-Motive
 
Posts: n/a

Default Re: Centering a Div - 10-23-2007 , 10:03 AM






Hi Mick,

Text-align:center; is the worst in my oppinion.
Reason is its a IE only method. and according to W3C standards should not do
anything but center-align text.
And IE does this to all elements.

The visually best method is position absolute and than -margin the half of he
width.
This method gives you the most control over how your page looks only problem
is that when the browser is smaller than the content most of the times u wont
get scrollbars and wont be able to see the menu or some things that are on the
side of the page.

The best method in my opinion is margin: 0 auto;
Only thing is that IE 6 and earlier don't pick this up.

hope this helps,
JK


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.