Twitter Bootstrap就像垂直导航栏一样

时间:2013-06-15 14:37:42

标签: twitter-bootstrap

我是bootstrap的新手,并且在创建像bootstrap这样的导航栏时遇到了问题。我花了很多时间尝试它,但无法搞清楚。 我想要的就像

enter image description here

这就是我找到的here

<div class="span3 bs-docs-sidebar">
<ul class="nav nav-list bs-docs-sidenav affix">
  <li class="active"><a href="#dropdowns"><i class="icon-chevron-right"></i> Dropdowns</a></li>
  <li class=""><a href="#buttonGroups"><i class="icon-chevron-right"></i> Button groups</a></li>
  <li><a href="#buttonDropdowns"><i class="icon-chevron-right"></i> Button dropdowns</a></li>
  <li><a href="#navs"><i class="icon-chevron-right"></i> Navs</a></li>
  <li><a href="#navbar"><i class="icon-chevron-right"></i> Navbar</a></li>
  <li><a href="#breadcrumbs"><i class="icon-chevron-right"></i> Breadcrumbs</a></li>
  <li><a href="#pagination"><i class="icon-chevron-right"></i> Pagination</a></li>
  <li><a href="#labels-badges"><i class="icon-chevron-right"></i> Labels and badges</a></li>
  <li><a href="#typography"><i class="icon-chevron-right"></i> Typography</a></li>
  <li><a href="#thumbnails"><i class="icon-chevron-right"></i> Thumbnails</a></li>
  <li><a href="#alerts"><i class="icon-chevron-right"></i> Alerts</a></li>
  <li><a href="#progress"><i class="icon-chevron-right"></i> Progress bars</a></li>
  <li><a href="#media"><i class="icon-chevron-right"></i> Media object</a></li>
  <li><a href="#misc"><i class="icon-chevron-right"></i> Misc</a></li>
</ul>

2 个答案:

答案 0 :(得分:11)

从twitter bootstrap的docs.css复制bs-sidebar的css; 添加另外的CSS,它在下面的同一文件的底部单独定义:

CSS

.bs-sidebar .nav > .active > ul {
    display: block;
    margin-bottom: 8px;
}

<强> HTML

<div class="bs-sidebar affix">
    <ul class="nav bs-sidenav">
        <li class="active"><a href="#">NAV1</a>
            <ul class="nav">
                <li><a href="#">1</a></li>
                <li><a href="#">2</a></li>
            </ul>
        </li>
        <li><a href="#">NAV2</a></li>
    </ul>
</div>

答案 1 :(得分:5)

你检查了bootstrap导航栏 - &gt;可堆叠部分,here

<ul class="nav nav-tabs nav-stacked">
  ...
</ul>

看起来和你问过的一样......试过这个吗?