我有一个使用 Bootstrap 制作的自定义导航栏,其中包含 3 个简单链接:主页、服务和联系人。就像现在一样,每个链接周围的框大小不同,因为每个链接包含不同数量的字符,如此处所示。我一直在尝试编辑我的代码,以便所有列表项的宽度为 100 像素,但没有任何变化。我该怎么做才能使链接周围的所有框都具有相同的宽度。
这是我导航的 HTML:
<div id="nav-wrapper">
<div id="nav" class="navbar navbar-inverse affix-top center" data-spy="affix">
<div class="navbar-inner" data-spy="affix-top">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<!-- Everything you want hidden at 940px or less, place within here -->
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="#home">Home</a></li>
<li><a href="#service-top">Services</a></li>
<li><a href="#contact-arrow">Contact</a></li>
</ul><!--/.nav-->
</div><!--/.nav-collapse collapse pull-right-->
</div><!--/.container-->
</div><!--/.navbar-inner-->
</div><!--/#nav /.navbar navbar-inverse-->
</div><!--/#nav-wrapper-->
这是我与导航相关的 CSS:
.navbar {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
padding:0;
z-index:999;
margin-bottom:0;
}
.navbar.navbar-inverse .navbar-inner {
background: #390 url(../img/green-bg.png) repeat;
border:none;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
margin-bottom:0;
}
.navbar .nav, .navbar .nav > li {
float:none;
display:inline-block;
*display:inline; /* ie7 fix */
*zoom:1; /* hasLayout ie7 trigger */
vertical-align: top;
padding:0 2em;
margin:0;
}
.navbar-inner {
text-align:center;
margin-bottom:0;
}
.navbar-inner ul.nav li {
text-align: center;
}
.navbar .nav > li a{
color:white;
background:rgba(0,0,0,0.2);
text-shadow:none;
font-size:1.5em;
font-family: marvel, serif;
padding:.5em 1em;
margin:.5em 1em;
}
.navbar .nav > .active a:hover, .navbar .nav > li a:hover, .navbar .nav > .active a {
color:white;
background: #390 url(../img/green-bg.png) repeat;
text-shadow:none;
font-size:1.5em;
font-family: marvel, serif;
padding:.5em 1em;
margin:.5em 1em;
-webkit-box-shadow: inset 0 0 10px #000;
-moz-box-shadow: inset 0 0 10px #000;
box-shadow: inset 0 0 10px #000;
}
.navbar .nav > li {
padding:1em;
margin:0;
}
#nav.affix, #nav.affix-bottom {
position: fixed;
top: 0;
width: 100%
}
#nav {
position:relative;
z-index:999;
-webkit-perspective: 1000; -webkit-backface-visibility: hidden;
}