element; the buttons are vertically centered in the navbar..navbar-btn can be used on and element in the page.
Do not use .navbar-nav element inside the element, use .navbar-btn , because it is not a standard button class 。
The following example demonstrates this:
Example
<nav class=">navbar navbar-default
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<form class=">navbar-form navbar-left
"
role
=
"
search
"
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" div>
<button type="submit" class=">btn btn-default
"
submit button
button
form
<button type="button" class=">btn btn-default navbar-btn
"
Navbar Buttons
button
div
div
nav
Try it »
The result is as follows:
Text in the Navbar
If you need to include a text string in the navigation, use the class .navbar-text . This is usually used together with the
tag to ensure proper leading and color. The following example demonstrates this:
Example
<nav class=">navbar navbar-default
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<p class="navbar-text">Runoob User Login
p
div
div
nav
Try it »
The result is as follows:
Navigation Links with Icons
If you want to use icons within a regular navbar navigation component, use the class glyphicon glyphicon- * to set the icon. For more, see Bootstrap Icons , as shown in the example below:
Example
<nav class=">navbar navbar-default
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<ul class=">nav navbar-nav navbar-right
"
<li>
<a href="">
<span class=">glyphicon glyphicon-user
"
span
Registration
a
li
<li>
<a href="">
<span class=">glyphicon glyphicon-log-in
"
span
Login
a
li
ul
div
nav
Try it »
The result is as follows:
Component Alignment
You can use the utility classes .navbar-left or .navbar-right to align the navigation links, forms, buttons, or text components in the navbar to the left or right. Both classes add CSS floats in the specified direction. The following example demonstrates this:
Example
<nav class=">navbar navbar-default
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<ul class=">nav navbar-nav navbar-left
"
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown" Java>
<b class="caret" b a>
<ul class="dropdown-menu">
<li>
<a href="" jmeter a li>
<li>
<a href="" EJB a li>
<li>
<a href="">Jasper Report
a
li
<li class="divider" li>
<li>
<a href="">Separated link
a
li
<li class="divider" li>
<li>
<a href="">Another separate link
a
li
ul
li
ul
<form class=">navbar-form navbar-left
"
role
=
"
search
"
<button type="submit" class=">btn btn-default
"
Left Align - Submit Button
button
form
<p class=">navbar-text navbar-left
"
Left Align - Text
p
<ul class=">nav navbar-nav navbar-right
"
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown" Java>
<b class="caret" b a>
<ul class="dropdown-menu">
<li>
<a href="" jmeter a li>
<li>
<a href="" EJB a li>
<li>
<a href="">Jasper Report
a
li
<li class="divider" li>
<li>
<a href="">Separated link
a
li
<li class="divider" li>
<li>
<a href="">Another separate link
a
li
ul
li
ul
<form class=">navbar-form navbar-right
"
role
=
"
search
"
<button type="submit" class=">btn btn-default
"
Right Align - Submit Button
button
form
<p class=">navbar-text navbar-right
"
Right Align - Text
p
div
div
nav
Try it »
The result is as follows:
Fixed to Top
The Bootstrap navbar can be positioned dynamically. By default, it is a block-level element, positioned based on where it is placed in the HTML. With some helper classes, you can place it at the top or bottom of the page, or you can make it a static navbar that scrolls with the page.
If you want the navbar fixed to the top of the page, add the .navbar class Add the class .navbar-fixed-top . The following example demonstrates this:
To prevent the navbar from overlapping with other content at the top of the page body, add at least 50 pixels of padding to the body tag; the padding value can be set according to your needs.
Example
<nav class=">navbar navbar-default navbar-fixed-top
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<ul class=">nav navbar-nav
"
<li class="active">
<a href="" iOS a li>
<li>
<a href="" SVN a li>
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown" Java>
<b class="caret" b a>
<ul class="dropdown-menu">
<li>
<a href="" jmeter a li>
<li>
<a href="" EJB a li>
<li>
<a href="">Jasper Report
a
li
<li class="divider" li>
<li>
<a href="">Separated link
a
li
<li class="divider" li>
<li>
<a href="">Another separate link
a
li
ul
li
ul
div
div
nav
Try it »
The result is as follows:
Fixed to Bottom
If you want the navbar fixed to the bottom of the page, add the .navbar class Add the class .navbar-fixed-bottom . The following example demonstrates this:
Example
<nav class=">navbar navbar-default navbar-fixed-bottom
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<ul class=">nav navbar-nav
"
<li class="active">
<a href="" iOS a li>
<li>
<a href="" SVN a li>
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown" Java>
<b class="caret" b a>
<ul class="dropdown-menu">
<li>
<a href="" jmeter a li>
<li>
<a href="" EJB a li>
<li>
<a href="">Jasper Report
a
li
<li class="divider" li>
<li>
<a href="">Separated link
a
li
<li class="divider" li>
<li>
<a href="">Another separate link
a
li
ul
li
ul
div
div
nav
Try it »
The result is as follows:
Static Top
To create a navbar that scrolls with the page, add the .navbar-static-top class. This class does not require adding padding to the body.
Example
<nav class=">navbar navbar-default navbar-static-top
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<ul class=">nav navbar-nav
"
<li class="active">
<a href="" iOS a li>
<li>
<a href="" SVN a li>
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown" Java>
<b class="caret" b a>
<ul class="dropdown-menu">
<li>
<a href="" jmeter a li>
<li>
<a href="" EJB a li>
<li>
<a href="">Jasper Report
a
li
<li class="divider" li>
<li>
<a href="">Separated link
a
li
<li class="divider" li>
<li>
<a href="">Another separate link
a
li
ul
li
ul
div
div
nav
Try it »
The result is as follows:
Inverse Navbar
To create an inverse navbar with a black background and white text, simply add the .navbar class to the .navbar-inverse class, as shown in the example below:
To prevent the navbar from overlapping with other content at the top of the page body, add at least 50 pixels of padding to the body tag; the padding value can be set according to your needs.
Example
<nav class=">navbar navbar-inverse
"
role
=
"
navigation
"
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Runoob Tutorial
a
div
<div>
<ul class=">nav navbar-nav
"
<li class="active">
<a href="" iOS a li>
<li>
<a href="" SVN a li>
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown" Java>
<b class="caret" b a>
<ul class="dropdown-menu">
<li>
<a href="" jmeter a li>
<li>
<a href="" EJB a li>
<li>
<a href="">Jasper Report
a
li
<li class="divider" li>
<li>
<a href="">Separated link
a
li
<li class="divider" li>
<li>
<a href="">Another separate link
a
li
ul
li
ul
div
div
nav
Try it »
The result is as follows: