I have a CSS menu here that works fine, honestly. The only thing I want to change about it is the location of the tabs. They all start at the left of the page, while I'd rather have them centered at the middle. margin: auto;
did not help me in this case. Can anyone look into this for me please?
Asked
Active
Viewed 40 times
0

areim
- 3,371
- 2
- 23
- 29

Coding Gal
- 145
- 1
- 12
3 Answers
2
Your current list items float to left which is making it start from left of the menu. Reset them to none and use display: inline-block
to align them in a line.
#cssmenu li {
float: none; /* Modify */
display: inline-block; /* Add */
padding: 0px;
}

m4n0
- 29,823
- 27
- 76
- 89
-
This worked for me, thank you! I'll choose your answer as the solution as soon as I'm able to! Thank you a million times! :D – Coding Gal Sep 14 '15 at 11:05
-
1
1
Set the margin in UL
to margin auto. Put the background in #cssmennu
.
CSS
#cssmenu {
position:relative;
border: none;
border: 0px;
margin: 0 auto;
background: #333333;
padding: 0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-weight: bold;
width: auto;
text-align:center;
}
#cssmenu ul {
background: #333333;
height: 35px;
list-style: none;
margin: 0 auto;
padding: 0;
width:1000px;
}
Check This DEMO

CodeRomeos
- 2,428
- 1
- 10
- 20
1
A simple solution would be:
#cssmenu {text-align: center;}
#cssmenu ul {display: inline-block;}

WingmanImd
- 142
- 6
menu?](http://stackoverflow.com/questions/2865380/how-do-i-center-align-horizontal-ul-menu)
– areim Sep 14 '15 at 11:08