我已经修复了这个菜单,如何使这个菜单居中?
我已经尝试使用 margin: 0 auto 和 float: left,但它不起作用。
有什么办法可以居中吗??
这里我有一个演示:
http://jsbin.com/enaliw/3/edit
<nav>
<ul id="main-nav" class="clearfix">
<li><a href="#;">Inicio</a></li>
<li><a href="#">Guia</a></li>
<li><a href="#">Heroes</a></li>
<li><a href="#">Videos</a></li>
<li><a href="#">ScreamShots</a></li>
</ul>
</nav>
CSS
#main-nav {
width: 100%;
margin: 0 auto;
padding: 0;
position: fixed;
left: 0;
/*bottom: 0;*/
z-index: 100;
background: #9dd53a; /* Old browsers */
background: -moz-linear-gradient(top, #9dd53a 26%, #a1d54f 47%, #80c217 67%, #7cbc0a 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(26%,#9dd53a), color-stop(47%,#a1d54f), color-stop(67%,#80c217), color-stop(100%,#7cbc0a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #9dd53a 26%,#a1d54f 47%,#80c217 67%,#7cbc0a 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #9dd53a 26%,#a1d54f 47%,#80c217 67%,#7cbc0a 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #9dd53a 26%,#a1d54f 47%,#80c217 67%,#7cbc0a 100%); /* IE10+ */
background: linear-gradient(to bottom, #9dd53a 26%,#a1d54f 47%,#80c217 67%,#7cbc0a 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9dd53a', endColorstr='#7cbc0a',GradientType=0 ); /* IE6-9 */
border-radius: 8px;}
#main-nav li {
position: relative;
margin: 0 auto;
padding: 0;
list-style: none;
float: left;}
#main-nav a {
margin: 0 auto;
line-height: 100%;
font-weight: bolder;
color: #000000;
display: block;
padding: 15px 20px;
text-decoration: none;}