loading

BS Tabs/Pills

Menus

Most web pages include some sort of menu.

In HTML, a menu is commonly defined in an unordered list <ul> (and then stylized), like this:

Example

				
					<ul>
  <li><a href="#">Home</a></li>
  <li><a href="#">Menu 1</a></li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

To build a horizontal menu from the list above, add the .list-inline class to <ul>.

				
					<ul class="list-inline">
				
			

Alternatively, you may display the menu above using Bootstrap’s Tabs and Pills (see below).

Note: See the final example on this page to learn how to make tabs and pills toggleable/dynamic.

Tabs

------list mukava -----

Tabs are made using <ul class=”nav nav-tabs”>:

Tip: Mark the current page using <li class=”active”>.

The following example generates navigation tabs.

Example

				
					<ul class="nav nav-tabs">
  <li class="active"><a href="#">Home</a></li>
  <li><a href="#">Menu 1</a></li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

Tabs With Dropdown Menu

------list mukava -----

Tabs can also contain dropdown menus.

The following example creates a dropdown menu for “Menu 1”:

Example

				
					<ul class="nav nav-tabs">
  <li class="active"><a href="#">Home</a></li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu 1
    <span class="caret"></span></a>
    <ul class="dropdown-menu">
      <li><a href="#">Submenu 1-1</a></li>
      <li><a href="#">Submenu 1-2</a></li>
      <li><a href="#">Submenu 1-3</a></li>
    </ul>
  </li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

Pills

------list mukava -----

Pills are made using <ul class=”nav nav-pills”>. Mark the current page as <li class=”active”>:

Example

				
					<ul class="nav nav-pills">
  <li class="active"><a href="#">Home</a></li>
  <li><a href="#">Menu 1</a></li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

Vertical Pills

------list mukava -----

Pills can also be arranged vertically. Simply add the .nav-stacked class:

Example

				
					<ul class="nav nav-pills nav-stacked">
  <li class="active"><a href="#">Home</a></li>
  <li><a href="#">Menu 1</a></li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

Vertical Pills in a Row

------list mukava -----

In the following example, the vertical pill menu is placed inside the last column. So, on a large screen, the menu will be displayed on the right. However, on a small screen, the material will automatically convert to a single-column layout:

Example

				
					<div class="col-md-3">
  <ul class="nav nav-pills nav-stacked">
    <li class="active"><a href="#">Home</a></li>
    <li><a href="#">Menu 1</a></li>
    <li><a href="#">Menu 2</a></li>
    <li><a href="#">Menu 3</a></li>
  </ul>
</div>
				
			

Pills With Dropdown Menu

------list mukava -----

Pills can also contain dropdown menus.

The following example creates a dropdown menu for “Menu 1”:

Example

				
					<ul class="nav nav-pills nav-stacked">
  <li class="active"><a href="#">Home</a></li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu 1
    <span class="caret"></span></a>
    <ul class="dropdown-menu">
      <li><a href="#">Submenu 1-1</a></li>
      <li><a href="#">Submenu 1-2</a></li>
      <li><a href="#">Submenu 1-3</a></li>
    </ul>
  </li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

Centered Tabs and Pills

------list mukava -----

The .nav-justified class can be used to center/justify tabs and pills.

Note that on screens smaller than 768px, the list elements are stacked (text remains centered):

Example

				
					<!-- Centered Tabs -->
<ul class="nav nav-tabs nav-justified">
  <li class="active"><a href="#">Home</a></li>
  <li><a href="#">Menu 1</a></li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>

<!-- Centered Pills -->
<ul class="nav nav-pills nav-justified">
  <li class="active"><a href="#">Home</a></li>
  <li><a href="#">Menu 1</a></li>
  <li><a href="#">Menu 2</a></li>
  <li><a href="#">Menu 3</a></li>
</ul>
				
			

Toggleable / Dynamic Tabs

------list mukava -----

To make the tabs toggleable, add the data-toggle=”tab” property to all links. Then, add a .tab-pane class with a unique ID for each tab and surround it inside a <div> element with class .tab-content.

To make the tabs fade in and out when clicked, add the .fade class to .tab-pane.

Example

				
					<ul class="nav nav-tabs">
  <li class="active"><a data-toggle="tab" href="#home">Home</a></li>
  <li><a data-toggle="tab" href="#menu1">Menu 1</a></li>
  <li><a data-toggle="tab" href="#menu2">Menu 2</a></li>
</ul>

<div class="tab-content">
  <div id="home" class="tab-pane fade in active">
    <h3>HOME</h3>
    <p>Some content.</p>
  </div>
  <div id="menu1" class="tab-pane fade">
    <h3>Menu 1</h3>
    <p>Some content in menu 1.</p>
  </div>
  <div id="menu2" class="tab-pane fade">
    <h3>Menu 2</h3>
    <p>Some content in menu 2.</p>
  </div>
</div>
				
			

Toggleable / Dynamic Pills

The same code works for pills; simply modify the data-toggle attribute to data-toggle=”pill“:

Example

				
					<ul class="nav nav-pills">
  <li class="active"><a data-toggle="pill" href="#home">Home</a></li>
  <li><a data-toggle="pill" href="#menu1">Menu 1</a></li>
  <li><a data-toggle="pill" href="#menu2">Menu 2</a></li>
</ul>

<div class="tab-content">
  <div id="home" class="tab-pane fade in active">
    <h3>HOME</h3>
    <p>Some content.</p>
  </div>
  <div id="menu1" class="tab-pane fade">
    <h3>Menu 1</h3>
    <p>Some content in menu 1.</p>
  </div>
  <div id="menu2" class="tab-pane fade">
    <h3>Menu 2</h3>
    <p>Some content in menu 2.</p>
  </div>
</div>
				
			
Share this Doc

BS Tabs/Pills

Or copy link

Explore Topic