...

View Full Version : center page in browser window



lauerm
04-23-2006, 07:14 PM
I want to center my site based on the browser width. I put in a container div, but it is still not working. Any suggestions? Do I need to change all my other divs to relative?

#container {
margin-left: auto;
margin-right: auto;
text-align: center;
}

kewlceo
04-23-2006, 07:43 PM
You have no width (percentage of viewport, for example) defined.

lauerm
04-23-2006, 07:59 PM
How about this? (Am I closer?)

#center{
position:relative;
text-align:center;
width:100%;
margin:0px;
padding:0px;
border:1px solid green;
}

#container {
position:relative;
width:800px;
height:550px;
margin:0;
text-align:center;
border:1px solid red;
}

kewlceo
04-23-2006, 08:17 PM
This is all it would take to make your main container:


#container {
width: 800px;
height: 550px;
margin: auto;
border: 1px solid red;
text-align: center;
}

lauerm
04-23-2006, 09:44 PM
got it - thanks!
http://64.72.10.16/~michellelauer/CIS184/final/index.html

kewlceo
04-23-2006, 10:14 PM
got it - thanks!
http://64.72.10.16/~michellelauer/CIS184/final/index.html
Beautiful job, Michelle, well done! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum