Can't get my navigation menu in the center of

2019-02-26 05:24发布

The navigation menu is not centered. I have tried many methods of getting it to be centered, but none worked.

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;
}   

标签: menu center
1条回答
老娘就宠你
2楼-- · 2019-02-26 05:37

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

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

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

Also, you weren't closing some of your css with } , so I added those in

查看更多
登录 后发表回答