...

View Full Version : centering in a Div



jcdevelopment
10-30-2007, 11:11 PM
I have a list menu that is placed in a div. For some reason when i type text-align:center it wont do anything, do i have to set a huge margin or padding left to it?

heres my css code:


#navctrl {
background-color: #336666;
width:100%;
height:25px;
position:absolute;
margin-top:75px;
margin-left:0px;
border-top:2px solid #FFFFFF;
border-bottom:2px solid #FFFFFF;
z-index:25;
font-family:Verdana, Arial, Helvetica, sans-serif;
color:#FFFFFF;
font-size:12px;
}


#navctrl li {
float:left;
position:relative;
list-style-type:none;
border-right:1px solid #000000;
text-align:center;
vertical-align:
}


thanks

jlhaslip
10-30-2007, 11:19 PM
It is absolutely positioned.

Might need to see some more code, or a link to the page would be best.

jcdevelopment
10-30-2007, 11:24 PM
well, is there anyway to get around the absolute position? There is only a div in the html section, not much code!

jlhaslip
10-30-2007, 11:40 PM
I rarely use position:absolute, myself, so yes, it can be avoided, but as for your page, I can't say, need to see some code, or ideally, a link to the page.

SnoringFrog
10-30-2007, 11:42 PM
It's hard to say w/o the full coding of the page, but I'd say just drop the "position:absolute;" if it doesn't screw up the rest of the page.

jcdevelopment
10-31-2007, 12:00 AM
im sorry, i thought position absolute was the best thing to use to place images right?

timgolding
10-31-2007, 12:09 AM
The only time you really need to have something absolutely positioned is if it must go over the top of something. I suggest using



div#outer
{
text-align:center;
}

div#inner
{
margin:0 auto;
}


P.S position:absolute has nothing to do with placing images. It is to do with how the box is positioned.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum