Bootstrap 3垂直导航栏

时间:2014-04-03 21:06:28

标签: html css twitter-bootstrap

我想用bootstrap 3创建导航栏 [vertical] 。 我尝试了这个,但它没有用。

<ul class="nav nav-pils nav-stacked">
     <li>jedan</li>
     <li>dva</li>
     <li>tri</li>
     <li>cetriri</li>
     <li>pet</li>
</ul>

我尝试了很多例子,但它都是旧的引导程序。如何使用新引导程序创建导航?

5 个答案:

答案 0 :(得分:23)

nav-pills课程需要两个l

<ul class="nav nav-pills nav-stacked">
   <li>jedan</li>
   <li>dva</li>
   <li>tri</li>
   <li>cetriri</li>
   <li>pet</li>
</ul>

http://getbootstrap.com/components/#nav-pills

答案 1 :(得分:7)

您似乎错过了l中的nav-pills(您将其列为nav-pils

<ul class="nav nav-pills nav-stacked">
   <li>jedan</li>
   <li>dva</li>
   <li>tri</li>
   <li>cetriri</li>
   <li>pet</li>
</ul>

http://getbootstrap.com/components/#nav-pills

答案 2 :(得分:6)

你可以使用药片,或者你可以写下这个:

你的HTML:

<!--navigation-->
<div class="navbar navbar-inverse navbar-fixed-left">
  <a class="navbar-brand" href="#">LOGO</a>
  <ul class="nav navbar-nav">
    <li><a href="#home"><i class="fa fa-home"></i><span> Link1 </span></a></li>
   <li><a href="#info"><i class="fa fa-info-circle"></i><span> Link2 </span></a></li>
   <li><a href="#love"><i class="fa fa-heart"></i><span> Link3 </span></a></li>
   <li><a href="#work"><i class="fa fa-briefcase"></i><span> Link4 </span></a></li>
   <li><a href="#contact"><i class="fa fa-envelope"></i><span> Link5 </span></a></li>
  </ul>
</div>
<!--end navigation-->
<!-- 1st section-->
<div class="wrapper">
<div class="container" id="home">
 <div class="row">
   <h2>Link 1</h2>
 </div>
</div>
<!-- 2nd section-->
  <div class="container" id="info">
 <div class="row">
   <h2>Link 2</h2>
 </div>
</div>
    <!--3rd section-->
    <div class="container" id="love">
 <div class="row">
   <h2>Link 3</h2>
 </div>
</div>
    <!--4th section-->
    <div class="container" id="work">
 <div class="row">
   <h2>Link 4</h2>
 </div>
</div>
    <!--5th section-->
    <div class="container" id="contact">
 <div class="row">
   <h2>Link 5</h2>
 </div>
</div>
</div>

你的css:

/* CSS used here will be applied after bootstrap.css */
.navbar-fixed-left {
  width: 140px;
  position: fixed;
  border-radius: 0;
  height: 100%;
}

.navbar-fixed-left .navbar-nav > li {
  float: none;  /* Cancel default li float: left */
  width: 139px;
}

.navbar-fixed-left + .container {
  padding-left: 160px;
}

.container {
  height: 1000px;
}

.wrapper {
  margin-left: 140px;
}

这里的工作示例:bootply

答案 3 :(得分:1)

使用navbar-pills。它会起作用。

答案 4 :(得分:1)

我来参加聚会但是如果你刚来到这里,你想在你的垂直导航中添加切换按钮:

<nav class="list-group"> 
   <ul class="nav">
    <li>
        <a href="#" id="btn-1" data-toggle="collapse" data-target="#submenu1" aria-expanded="false" class="list-group-item">Item 1
        </a>
     <ul class="nav collapse" id="submenu1" role="menu" aria-labelledby="btn-1">
        <li>
            <a href="#" class="list-group-item">
                Item 2
            </a>
        </li>
        <li>
        <a href="#" class="list-group-item">
                Item 3
            </a>
        </li>
      </ul>
    </li>
  </ul>
</nav>