Simple Fixed Navbar in Bootstrap

Simple Fixed Navbar in Bootstrap
Project: Simple fixed navbar and mobile-friendly sticky footer
Author: MrPirrera
Edit Online: View on CodePen
License: MIT

This code snippet helps you to create a simple fixed navbar in Bootstrap. It uses Bootstrap default navbar template with “navbar-fixed-top” class to make the menu fixed on top of the webpage.

How to Create Simple Fixed Navbar

Create the HTML structure for Bootstrap navbar as follows:

<!-- navbar -->
    <div class="navbar navbar-default navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          <a class="navbar-brand" href="#">Project name</a>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
  </div><!-- /navbar -->

Style using the navbar by adding the following CSS styles to your project:

@import "//";

html {
    position: relative;
    min-height: 100%;
body {
    margin: 0 0 60px; /* bottom has to be the same as footer height */
footer {
    /* just for demo */
    background-color: #F8F8F8;
    border-top: 1px solid #E7E7E7;
   /* just for demo */ 
    position: absolute;
    left: 0;
    bottom: 0;
    height: 60px;
    width: 100%;

That’s all! hopefully, you have successfully created a simple fixed navbar. If you have any questions or suggestions, feel free to comment below.

Leave a Comment


No comments yet. Why don’t you start the discussion?

Leave a Reply