本文介绍了无法在页面中央找到我的导航菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导航菜单未居中.我尝试了很多方法来使它居中,但没有一个奏效.

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

推荐答案

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

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

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

此外,您并没有使用}关闭某些CSS,所以我在其中添加了这些

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

这篇关于无法在页面中央找到我的导航菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 05:38