Martes, 07 Mayo 2024

All nav components here—tabs, pills, and lists—share the same base markup and styles through the .nav class.

Basic tabs

Take a regular <ul> of links and add .nav-tabs:

  1. <ul class="nav nav-tabs">
  2.  <li class="active">
  3.  <a href="#">Home</a>
  4.  </li>
  5.  <li><a href="#">...</a></li>
  6.  <li><a href="#">...</a></li>
  7. </ul>

Basic pills

Take that same HTML, but use .nav-pills instead:

  1. <ul class="nav nav-pills">
  2.  <li class="active">
  3.  <a href="#">Home</a>
  4.  </li>
  5.  <li><a href="#">...</a></li>
  6.  <li><a href="#">...</a></li>
  7. </ul>

Disabled state

For any nav component (tabs, pills, or list), add .disabled for gray links and no hover effects. Links will remain clickable, however, unless custom javascript is implemented to prevent those clicks.

  1. <ul class="nav nav-pills">
  2. ...
  3.  <li class="disabled"><a href="#">Home</a></li>
  4. ...
  5. </ul>

Component alignment

To align nav links, use the .pull-left or .pull-right utility classes. Both classes will add a CSS float in the specified direction.


Stackable

As tabs and pills are horizontal by default, just add a second class, .nav-stacked, to make them appear vertically stacked.

Stacked tabs

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

Stacked pills

  1. <ul class="nav nav-pills nav-stacked">
  2. ...
  3. </ul>

Dropdowns

Add dropdown menus with a little extra HTML and the dropdowns javascript plugin.

Tabs with dropdowns

  1. <ul class="nav nav-tabs">
  2.  <li class="dropdown">
  3.  <a class="dropdown-toggle"
  4.  data-toggle="dropdown"
  5.  href="#">
  6. Dropdown
  7.  <b class="caret"></b>
  8.  </a>
  9.  <ul class="dropdown-menu">
  10.  <!-- links -->
  11.  </ul>
  12.  </li>
  13. </ul>

Pills with dropdowns

  1. <ul class="nav nav-pills">
  2.  <li class="dropdown">
  3.  <a class="dropdown-toggle"
  4.  data-toggle="dropdown"
  5.  href="#">
  6. Dropdown
  7.  <b class="caret"></b>
  8.  </a>
  9.  <ul class="dropdown-menu">
  10.  <!-- links -->
  11.  </ul>
  12.  </li>
  13. </ul>

Nav lists

A simple and easy way to build groups of nav links with optional headers. They're best used in sidebars like the Finder in OS X.

Example nav list

Take a list of links and add class="nav nav-list":

  1. <ul class="nav nav-list">
  2.  <li class="nav-header">List header</li>
  3.  <li class="active"><a href="#">Home</a></li>
  4.  <li><a href="#">Library</a></li>
  5. ...
  6. </ul>

Note For nesting within a nav list, include class="nav nav-list" on any nested <ul>.

Horizontal dividers

Add a horizontal divider by creating an empty list item with the class .divider, like so:

  1. <ul class="nav nav-list">
  2. ...
  3.  <li class="divider"></li>
  4. ...
  5. </ul>

Tabbable nav

Bring your tabs to life with a simple plugin to toggle between content via tabs. Bootstrap integrates tabbable tabs in four styles: top (default), right, bottom, and left.

Tabbable example

To make tabs tabbable, create a .tab-pane with unique ID for every tab and wrap them in .tab-content.

I'm in Section 1.

Howdy, I'm in Section 2.

What up girl, this is Section 3.

  1. <div class="tabbable"> <!-- Only required for left/right tabs -->
  2.  <ul class="nav nav-tabs">
  3.  <li class="active"><a href="#tab1" data-toggle="tab">Section 1</a></li>
  4.  <li><a href="#tab2" data-toggle="tab">Section 2</a></li>
  5.  </ul>
  6.  <div class="tab-content">
  7.  <div class="tab-pane active" id="tab1">
  8.  <p>I'm in Section 1.</p>
  9.  </div>
  10.  <div class="tab-pane" id="tab2">
  11.  <p>Howdy, I'm in Section 2.</p>
  12.  </div>
  13.  </div>
  14. </div>

Fade in tabs

To make tabs fade in, add .fade to each .tab-pane.

Requires jQuery plugin

All tabbable tabs are powered by our lightweight jQuery plugin. Read more about how to bring tabbable tabs to life on the javascript docs page.

Tabbable in any direction

Tabs on the bottom

Flip the order of the HTML and add a class to put tabs on the bottom.

I'm in Section A.

Howdy, I'm in Section B.

What up girl, this is Section C.

  1. <div class="tabbable tabs-below">
  2.  <div class="tab-content">
  3. ...
  4.  </div>
  5.  <ul class="nav nav-tabs">
  6. ...
  7.  </ul>
  8. </div>

Tabs on the left

Swap the class to put tabs on the left.

I'm in Section A.

Howdy, I'm in Section B.

What up girl, this is Section C.

  1. <div class="tabbable tabs-left">
  2.  <ul class="nav nav-tabs">
  3. ...
  4.  </ul>
  5.  <div class="tab-content">
  6. ...
  7.  </div>
  8. </div>

Tabs on the right

Swap the class to put tabs on the right.

I'm in Section A.

Howdy, I'm in Section B.

What up girl, this is Section C.

  1. <div class="tabbable tabs-right">
  2.  <ul class="nav nav-tabs">
  3. ...
  4.  </ul>
  5.  <div class="tab-content">
  6. ...
  7.  </div>
  8. </div>