PDA

View Full Version : centering a div


Kostaben
08-17-2007, 07:36 AM
Hello everyone,

Does anyone can tell me how to center verticaly a div, in a way that stays in the midle of the browser window, whatever the window´s width?

Thanks in advanced.

-fedexer-
08-17-2007, 10:52 AM
Well i saw you asking in my thread how to do it, and now that ive figured it out i can share it , although domedia could probably explain it better.

First make a Div (the one on the left of the AP Div button) now thats going to be the "main" Div, so give it an ID like.. "Main" or something.

Next go into code mode and you should see somewhere near the bottom:

<div id="Whats you called your Div"></div>


Ok you need to change that code to :

<div align="center" id="Whats you called your Div"></div>


Ok that centers the main div, next you need to make a CSS rule for it, so make a rule as follows:

#whateveryoucalledthediv {
position:relative;
}


Ok almost done, then all you need to do is nest the other Div's you want (these can be AP Div's, inside the main div.)

For more on nesting Div's go to your dreamweaver help and search for:
"Work with nested AP Divs"

Well i hope that helps you, and if anyone else wants to throw in some information please do ;-)

-fedexer-

m1a2x3x7
08-17-2007, 02:23 PM
set your margin to auto
ex.
#wrapper {
width: 700px;
height: 800px;
margin:auto;
}

domedia
08-17-2007, 03:17 PM
plus text-align: center in the for BDOY.
All explained here:
http://www.dreamweaverclub.com/css-center-content.php

Kostaben
08-17-2007, 03:44 PM
oufff. Finally i got it.
Thanks to all for the help