Bootstrap导航栏调整大小

时间:2013-04-13 06:51:34

标签: html css graphics twitter-bootstrap web

我正在使用bootstrap来构建一个简单的网站,但我对导航栏的高度有些麻烦。所以当标题不太长时,导航条看起来很好:
enter image description here

但是,如果其中一个链接名称太长,则导航栏看起来像这样:
enter image description here

这是我的HTML代码:

<div class="container">
    <div class="masthead">
        <div class="navbar">
            <div class="navbar-inner">                    
                <ul class="nav">
                    <li class="active"><a href="../Home.html">Home</a></li>
                    <li><a href="../About.html">About</a></li>
                    <li><a href="../Officers.html">Officers</a></li>
                    <li><a href="../Join.html">Join</a></li>
                    <li><a href="../Calendar.html">Calendar</a></li>
                    <li><a href="../Contact.html">Contact</a></li>
                    <li><a href="../WSP.html">Wsdf asdkfjlaksjdf laksjdflkjasdf</a></li>
                    <li><a href="../Members.html">Members</a></li>
                </ul>                    
            </div><!-- /.navbar-inner -->
        </div><!-- /.navbar -->
    </div><!-- /.masthead -->
</div><!-- /.container -->

我的CSS看起来像这样:

/* Customize the navbar links to be fill the entire space of the .navbar */
.navbar .navbar-inner {
    padding: 0;
}
.navbar .nav {
    margin: 0;
    display: table;
    width: 100%;
}
.navbar .nav li {
    display: table-cell;
    width: 1%;
    float: none;
}
.navbar .nav li a {
    font-weight: bold;
    text-align: center;
    border-left: 1px solid rgba(255,255,255,.75);
    border-right: 1px solid rgba(0,0,0,.1);
}
.navbar .nav li:first-child a {
    border-left: 0;
    border-radius: 3px 0 0 3px;
}
.navbar .nav li:last-child a {
    border-right: 0;
    border-radius: 0 3px 3px 0;
}

如何调整CSS代码以使导航栏图形正确调整?

1 个答案:

答案 0 :(得分:2)

.navbar .nav li {
    display: table-cell;
    width: 1%;
    float: none;
    border-left: 1px solid rgba(255,255,255,.75);
    border-right: 1px solid rgba(0,0,0,.1);
    vertical-align:middle;
}
.navbar .nav li a {
    font-weight: bold;
    text-align: center;

}
.navbar .nav li:first-child {
    border-left: 0;
    border-radius: 3px 0 0 3px;
}
.navbar .nav li:last-child {
    border-right: 0;
    border-radius: 0 3px 3px 0;
}

.navbar .nav > .active {
  color: #555555;
  text-decoration: none;
  background-color: #e5e5e5;
  -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
     -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
          box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
}

试试这个可以解决你的问题