Forum Moderators: not2easy

Message Too Old, No Replies

Positioning menu divs in the centre of the page

text-align: center; and align:center have no success.

         

mentalacrobatics

9:46 pm on Apr 7, 2005 (gmt 0)

10+ Year Member



Hi
Thanks for all your help.
I am trying to get the items in this menu to centre in the middle of the page but I’ve been stumped. I’ve tried adding text-align: center; and align:center with no success. Any help would be appreciated!
Thanks:


<html>
<head>

<style type="text/css">

#navlist
{
margin: 0;
padding: 0 0 20px 10px;
border-bottom: 1px solid #000;

}

#navlist ul, #navlist li
{
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}

#navlist a:link, #navlist a:visited
{
float: left;
line-height: 14px;
font-weight: bold;
margin: 0 10px 4px 10px;
text-decoration: none;
color: #999;

}

#navlist a:link#current, #navlist a:visited#current, #navlist a:hover
{
border-bottom: 4px solid #000;
padding-bottom: 2px;
background: transparent;
color: #000;

}

#navlist a:hover { color: #000; }

</style>

</head>
<body>

<div id="navcontainer" align="center">
<ul id="navlist">
<li id="active"><a href="#" id="current">Item one</a></li>
<li><a href="#">Item two</a></li>

<li><a href="#">Item three</a></li>
<li><a href="#">Item four</a></li>
<li><a href="#">Item five</a></li>
</ul>
</div>

</body>
</html>

jfjet

4:20 am on Apr 9, 2005 (gmt 0)

10+ Year Member



Vertical centering isn't very intuitive using CSS, just do a web search for "vertical align center CSS", and you should see plenty of tips and techniques to achieve that. But I personally haven't seen one solution that works perfectly across ALL browsers. You may have to sacrifice this effect in a few unpopular browsers.

Moby_Dim

8:43 am on Apr 9, 2005 (gmt 0)

10+ Year Member



place one DIV so :
position : absolute;
top : 50%;
left : 0;
width : 100%;

then place another DIV inside the first one so :
position : absolute;
width : Xpx;
height : Ypx;
top : -Y/2px;
left : 50%;
margin-left : -X/2px;

X and Y are your choosed values.

mentalacrobatics

9:08 am on Apr 9, 2005 (gmt 0)

10+ Year Member



Thank you both.
I will work with your suggestions today.