Bootstrap Navigation Bar

A navigation bar is like a navigation header that is placed at the top of the page. You can collapse or extend it according to the screen size.

You can create a standard navigation bar at the top of the page with with <nav class=”navbar navbar-default”>.

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Case</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<nav class="navbar navbar-default">  

  <div class="container-fluid">  

    <div class="navbar-header">  

      <a class="navbar-brand" href="#">WebSiteName</a>  

    </div>  

    <ul class="nav navbar-nav">  

      <li class="active"><a href="#">Home</a></li>  

      <li><a href="#">Page 1</a></li>  

      <li><a href="#">Page 2</a></li>  

      <li><a href="#">Page 3</a></li>  

    </ul>  

  </div>  

</nav>  

    

<div class="container">  

  <h3>Basic Navbar Example</h3>  

  <p>A navigation bar is a navigation header that is placed at the top of the page.</p>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html>

Bootstrap Inverted Navigation Bar

Inverted navigation bar provides an alternative black navbar. It can be used to style the default navigation bar by changing .navbar-default class into .navbar-inverse class .

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Case</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<nav class="navbar navbar-inverse">  

  <div class="container-fluid">  

    <div class="navbar-header">  

      <a class="navbar-brand" href="#">WebSiteName</a>  

    </div>  

    <ul class="nav navbar-nav">  

      <li class="active"><a href="#">Home</a></li>  

      <li><a href="#">Page 1</a></li>  

      <li><a href="#">Page 2</a></li>  

      <li><a href="#">Page 3</a></li>  

    </ul>  

  </div>  

</nav>  

    

<div class="container">  

  <h3>Inverted Navbar</h3>  

  <p>An inverted navbar is black instead of gray.</p>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html> 

Bootstrap Navigation Bar with Dropdown

You can also add dropdown menu with navigation bars. The following example adds a dropdown menu for the “page 1” button.

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Case</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<nav class="navbar navbar-inverse">  

  <div class="container-fluid">  

    <div class="navbar-header">  

      <a class="navbar-brand" href="#">WebSiteName</a>  

    </div>  

    <ul class="nav navbar-nav">  

      <li class="active"><a href="#">Home</a></li>  

      <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>  

        <ul class="dropdown-menu">  

          <li><a href="#">Page 1-1</a></li>  

          <li><a href="#">Page 1-2</a></li>  

          <li><a href="#">Page 1-3</a></li>  

        </ul>  

      </li>  

      <li><a href="#">Page 2</a></li>  

      <li><a href="#">Page 3</a></li>  

    </ul>  

  </div>  

</nav>  

    

<div class="container">  

  <h3>Navbar With Dropdown</h3>  

  <p>This example adds a dropdown menu for the "Page 1" button in the navigation bar.</p>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html>

Bootstrap Right-Aligned Navigation Bar

Use the .navbar-right class to right-align navigation bar buttons. In the following example, we add “Sign Up”and “Log in” button to the right in the navigation bar.

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Case</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<nav class="navbar navbar-inverse">  

  <div class="container-fluid">  

    <div class="navbar-header">  

      <a class="navbar-brand" href="#">WebSiteName</a>  

    </div>  

    <ul class="nav navbar-nav">  

      <li class="active"><a href="#">Home</a></li>  

      <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>  

        <ul class="dropdown-menu">  

          <li><a href="#">Page 1-1</a></li>  

          <li><a href="#">Page 1-2</a></li>  

          <li><a href="#">Page 1-3</a></li>  

        </ul>  

      </li>  

      <li><a href="#">Page 2</a></li>  

      <li><a href="#">Page 3</a></li>  

    </ul>  

    <ul class="nav navbar-nav navbar-right">  

      <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>  

      <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>  

    </ul>  

  </div>  

</nav>  

    

<div class="container">  

  <h3>Right Aligned Navbar</h3>  

  <p>The .navbar-right class is used to right-align navigation bar buttons.</p>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html> 

Basic Navbar

In Bootstrap 4, you can extend or collapse a navigation bar depending on the screen size. A standard navigation bar is created with the .navbar class, followed by a responsive collapsing class: .navbar-expand-xl|lg|md|sm (stacks the navbar vertically on extra-large, large, medium or small screens).

To add links inside the navbar, use a <ul> element with class=”navbar-nav”. Then add <li> elements with a .nav-item class followed by an <a> element with a .nav-link class.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">   

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

  

<div class="container-fluid">  

  <h3>Basic Navbar Example</h3>  

  <p>A navigation bar is a navigation header that is placed at the top of the page.</p>  

    

</div>  

<nav class="navbar navbar-expand-sm bg-light">  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 1</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 2</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 3</a>  

    </li>  

  </ul>  

</nav>  

<br>  

</body>  

</html>

Vertical Navbar

If you want to create a vertical navigation bar, remove the .navbar-expand-xl|lg|md|sm class.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

  

<div class="container-fluid">  

  <h3>Vertical Navbar Example</h3>  

  <p>A navigation bar is a navigation header that is placed at the top of the page.</p>  

</div>  

  

<nav class="navbar bg-light">  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 1</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 2</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 3</a>  

    </li>  

  </ul>  

</nav>  

<br>  

  

</body>  

</html>  

Colored Navbar

You can use any of the .bg-color classes to change the background color of the navbar (.bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light).

Note: Add a white text color to all links in the navbar with the .navbar-dark class, or use the .navbar-light class to add a black text color.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<div class="container">  

  <h3>Colored Navbar Example</h3>  

   

</div>  

<nav class="navbar navbar-expand-sm bg-light navbar-light">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-primary navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-success navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-info navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-warning navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-danger navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

<nav class="navbar navbar-expand-sm bg-secondary navbar-dark">  

  <ul class="navbar-nav">  

    <li class="nav-item active">  

      <a class="nav-link" href="#">Active</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link disabled" href="#">Disabled</a>  

    </li>  

  </ul>  

</nav>  

</body>  

</html> 

Brand / Logo

The .navbar-brand class is used to highlight the brand/logo/project name of your page.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  

  <!-- Brand/logo -->  

  <a class="navbar-brand" href="#">Logo</a>  

    

  <!-- Links -->  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 1</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 2</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 3</a>  

    </li>  

  </ul>  

</nav>  

  

<div class="container-fluid">  

  <h3>Brand / Logo</h3>  

</div>  

  

</body>  

</html>

If you use .navbar-brand class on images, Bootstrap 4 will automatically style the image to fit the navbar.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  

  <!-- Brand/logo -->  

  <a class="navbar-brand" href="#">  

    <img src="image" alt="logo" style="width:40px;">  

  </a>  

  <!-- Links -->  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 1</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 2</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 3</a>  

    </li>  

  </ul>  

</nav>  

<div class="container-fluid">  

  <h3>Brand / Logo</h3>  

</div>  

</body>  

</html>  

Navbar Forms and Buttons

The <form> element with class=”form-inline” is used to group inputs and buttons side-by-side.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  

  <form class="form-inline" action="/action_page.php">  

    <input class="form-control" type="text" placeholder="Search">  

    <button class="btn btn-success" type="submit">Search</button>  

  </form>  

</nav>  

<br>  

<div class="container">  

  <h3>Navbar Forms</h3>  

  <p>Use the .form-inline class to align form elements side by side inside the navbar.</p>  

</div>  

</body>  

</html> 

You can also use other input classes, such as .input-group-addon to attach an icon or help text next to the input field. You will learn more about these classes in the Bootstrap Inputs chapter.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  

  <form class="form-inline">  

    <div class="input-group">  

      <span class="input-group-addon">@</span>  

      <input type="text" class="form-control" placeholder="Username">  

    </div>      

  </form>  

</nav>  

<br>  

<div class="container">  

  <h3>Navbar Forms</h3>  

  <p>Use the .form-inline class to align form elements side by side inside the navbar.</p>  

</div>  

</body>  

</html> 

Navbar Text

The .navbar-text class is used to vertical align any elements inside the navbar that are not links. You must ensure the proper padding and text color.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark">  

  <!-- Links -->  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 1</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link 2</a>  

    </li>  

  </ul>  

  <!-- Navbar text-->  

  <span class="navbar-text">  

    Navbar text  

  </span>  

</nav>  

<br>  

<div class="container">  

  <h3>Navbar Text</h3>  

</div>  

</body>  

</html>  

Fixed Navigation Bar

You can make navigation bar to be fixed at the top or at the bottom of the page. The fixed navigation bar stays visible at a fixed position (top or bottom) without depending on page scrolling.

Top Fixed navbar

The .fixed-top class makes the navigation bar fixed at the top.

Example:

!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body style="height:1500px">  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">  

  <a class="navbar-brand" href="#">Logo</a>  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

  </ul>  

</nav>  

<div class="container-fluid" style="margin-top:80px">  

  <h3>Top Fixed Navbar</h3>  

</div>  

</body>  

</html>

Bottom Fixed Navbar

The .fixed-bottom class is used to make the navbar stay at the bottom of the page.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body style="height:1500px">  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-bottom">  

  <a class="navbar-brand" href="#">Logo</a>  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="javascript:void(0)">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="javascript:void(0)">Link</a>  

    </li>  

  </ul>  

</nav>  

<div class="container-fluid"><br>  

  <h3>Bottom Fixed Navbar</h3>  

  <h1>Scroll this page to see the effect</h1>  

</div>  

</body>  

</html> 

Sticky Navbar

A sticky navigation bar stays fixed at the top of the page when you scroll past it. You can see the effect by scrolling this page.

Note: This facility doesn’t work in IE11 and earlier version.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body style="height:1500px">  

  

<div class="container-fluid">  

  <br>  

  <h3>Sticky Navbar</h3>  

  <p>You can see the effect by scrolling this page.</p>  

  <p><strong>Note:</strong> This facility doesn't work in IE11 and earlier version. </p>  

</div>  

  

<nav class="navbar navbar-expand-sm bg-dark navbar-dark sticky-top">  

  <a class="navbar-brand" href="#">Logo</a>  

  <ul class="navbar-nav">  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

    <li class="nav-item">  

      <a class="nav-link" href="#">Link</a>  

    </li>  

  </ul>  

</nav>  

  

<div class="container-fluid"><br>  

  <p>Some example text. Some example text. Some example text. Some example text. Some example text.</p>  

  <p>Some example text. Some example text. Some example text. Some example text. Some example text.</p>  

  <p>Some example text. Some example text. Some example text. Some example text. Some example text.</p>  

  <p>Some example text. Some example text. Some example text. Some example text. Some example text.</p>  

</div>  

  

</body>  

</html>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *