BS NavBar
Navigation Bars
A navigation bar is a navigation header that is located at the top of the page.
------list mukava -----
Bootstrap allows a navigation bar to grow or shrink based on screen size.
The <nav class=”navbar navbar-default”> element creates a typical navigation bar.
The example below demonstrates how to add a navigation bar at the top of the page.
Example
Note: All of the examples on this page will have a navigation bar that takes up too much space on small displays. This problem (with small screens) will be addressed in the final example on this page.
Inverted Navigation Bar
If you don’t like the style of the default navigation bar, Bootstrap offers an alternative, black navbar.
------list mukava -----
Simply update the .navbar-default class to .navbar-inverse:
Example
Right-Aligned Navigation Bar
------list mukava -----
To align the navigation bar buttons to the right, use the .navbar-right class.
In the following example, we add a “Sign Up” and a “Login” button to the right of the navigation bar. We also add a glyphicon to each of the two new buttons.
Example
Navbar Buttons
------list mukava -----
To add buttons inside the navbar, apply the .navbar-btn class to a Bootstrap button:
Example
Navbar Forms
------list mukava -----
To include form elements in the navbar, apply the .navbar-form class to a form element and add an input(s). We’ve added the .form-group class to the div container that holds the input. This adds adequate padding if you have several inputs (more on this in the Forms chapter).
Example
You can also use the .input-group and .input-group-addon classes to place an icon or help text next to an input field. You may learn more about these classes in the Bootstrap Inputs chapter.
Example
Fixed Navigation Bar
The navigation bar can be positioned at the top or bottom of the page.
A fixed navigation bar remains visible (top or bottom) regardless of page scroll.
------list mukava -----
The .navbar-fixed-top class fixes the navigation bar at the top.
Example
The .navbar-fixed-bottom class keeps the navigation bar at the bottom:
Example
Collapsing The Navigation Bar
The navigation bar frequently takes up too much space on a small screen.
We should conceal the navigation bar and only show it when necessary.
In the example below, the navigation bar is replaced by a button in the upper right corner. The navigation bar will only appear after clicking the button: