无法将我的导航菜单放在页面中央

时间:2014-03-02 07:30:23

标签: menu center

导航菜单未居中。我已经尝试了许多方法让它居中,但没有一个工作。

HTML

<div id="nav-bar">
<li> <a href="index.html">Home</a> </li>    
<li> <a href="servicii.html">Servicii</a> </li>    
<li> <a href="portofoliu.html">Portofoliu</a> </li>    
<li> <a href="contact.html">Contact</a> </li>

CSS

#nav-bar li a {
color: #000;
text-decoration: none;
list-style-type: none;
font-size: 14px;
font-family: "Myriad Pro", "Myriad Pro Cond", "Myriad Pro Light", Arial, sans-serif;
font-weight: bold;

#nav-bar {
text-transform: uppercase;
list-style: none;
padding: 23px 0 23px 0;
background-image: url(../images/nav-bar.jpg);

#nav-bar li {
float: left;
margin-right: 58px;
margin-left: 58px;
margin-top: -8px;
}   

1 个答案:

答案 0 :(得分:1)

http://jsfiddle.net/NLfaz/4/

#nav-bar {
   text-align: center;
}

#nav-bar li {
   float: left;  /* removed this line */
   display: inline-block;
}

另外,你没有用}关闭你的某些css,所以我在

中添加了这些