Kajzer
Kajzer

Reputation: 2385

Centering an UL inside a DIV

#nav 
{
border-style:solid;
width:500px;
height:20px;
margin-top:200px;
margin-left:auto;
margin-right:auto;
}
#nav ul   
{
list-style-type:none;
width:100%;
display:block;
margin-left:auto;
margin-right:auto;
}
 #nav li
{
display:inline;
}
#nav a
{
float:left;
display:block;
border-style:solid;
padding-left:5px;
padding-right:5px;
margin-top:-19px;
}

I just can't get it to center inside the div with the id "nav". Any help on what I am doing wrong? I am sort of new in this field, so any advice on how to make good css layouts would be appreciated!

Upvotes: 1

Views: 670

Answers (1)

Vincent Briglia
Vincent Briglia

Reputation: 3068

I think this should do the trick:

#nav {
    text-align: center;
}
#nav ul {
    margin: 0 auto; 
    text-align: left;
}

Upvotes: 1

Related Questions