只是匆匆忙忙,我可能在这里很傻,但无论如何:
我有一个以边距居中定位的导航,它有一个链接列表,我遇到的问题是因为我的所有<li>
类都被赋予了 css:float:left
它们在左侧对齐。
例如:
我想知道是否有任何方法可以使这些居中?
谢谢
CSS:
section#nav {
height: 45px;
margin-bottom:5px;
text-align:center;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
nav {
max-width: 700px;
height: 45px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
margin: 0 auto;
}
nav ul {
padding:12px 15px;
margin:0 auto;
text-align:center;
overflow:hidden;
}
nav ul li {
font-size:14px;
float:left;
}
nav ul li a {
color: #FFFFFF;
margin:0 10px;
transition: all 0.5s ease-out !important;
-moz-transition: all 0.5s ease-out !important;
-ms-transition: all 0.5s ease-out !important;
-webkit-transition: all 0.5s ease-out !important;
-o-transition: all 0.5s ease-out !important;
}
nav ul li a.nav-path-selected {
border-bottom:1px #ffffff solid;
}
nav ul li a.nav-path-selected {
border-bottom:1px #ffffff solid;
color:#FFFFFF !important;
}
nav ul li a:hover {
color:#CCCCCC !important;
transition: all 0.5s ease-out !important;
-moz-transition: all 0.5s ease-out !important;
-ms-transition: all 0.5s ease-out !important;
-webkit-transition: all 0.5s ease-out !important;
-o-transition: all 0.5s ease-out !important;
}
HTML:
<section id="nav">
<nav>
<ul class="nav">
<li class="nav-selected nav-path-selected">
<a class="nav-selected nav-path-selected" href="/">Home</a>
</li>
<li>
<a href="/about/">About Us</a>
</li>
<li>
<a href="/opportunities/">Opportunities</a>
</li>
<li>
<a href="/inspiration/">Inspiration</a>
</li>
<li>
<a href="/members/">Members</a>
</li>
</ul>
</nav>
</section>