How to add hamburger menu in bootstrap

I need some help with bootstrap nav. I want it to be toggled via a hamburger icon on mobile.

Here it is on codepen: (link invalid)

.navbar, .navbar-inverse { border-radius: 0; border: none; margin-bottom: 0; min-height: 80px; } .nav li { display: inline; color: white; } .navbar-inverse .navbar-nav>li>a { color: #ffffff; font-family: Lato; font-size: 1.7em; font-weight: 300; padding: 30px 25px 33px 25px; } .navbar-inverse .navbar-nav li a:hover { background-color: #444444; transition: 0.7s all linear; height: 100%; }
<script src=""></script> <script src=""></script> <link rel="stylesheet" href=""> <nav> <div> <ul> <li><a href="index.php">Home</a></li> <li><a href="about.php">About</a></li> <li><a href="#portfolio">Portfolio</a></li> <li><a href="#">Blog</a></li> <li><a href="contact.php">Contact</a></li> </ul> </div> </nav>
0

3 Answers

All you have to do is read the code on getbootstrap.com:

Codepen

<script src=""></script> <script src=""></script> <link rel="stylesheet" href=""> <nav> <div> <div> <button type="button"> <span>Toggle navigation</span> <span></span> <span></span> <span></span> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div> <ul> <li><a href="index.php">Home</a></li> <li><a href="about.php">About</a></li> <li><a href="#portfolio">Portfolio</a></li> <li><a href="#">Blog</a></li> <li><a href="contact.php">Contact</a></li> </ul> </div> </div> </nav>
12

To create icon you can use Glyphicon in Bootstrap:

<a href="#"> <span></span> </a> 

And then control size of icon in css:

.glyphicon-menu-hamburger { font-size: npx; } 
3

CSS only (no icon sets) Codepen

.nav-link #navBars { margin-top: -3px; padding: 8px 15px 3px; border: 1px solid rgba(0,0,0,.125); border-radius: .25rem; } .nav-link #navBars input { display: none; } .nav-link #navBars span { position: relative; z-index: 1; display: block; margin-bottom: 6px; width: 24px; height: 2px; background-color: rgba(125, 125, 126, 1); border-radius: .25rem; }
<link href="" rel="stylesheet"/> <nav> <!-- <a href="#"> <img src="" width="30" height="30" alt=""> Bootstrap </a> --> <!-- --> <a href="#"> <div> <input type="checkbox" /><span></span> <span></span> <span></span> </div> </a> <!-- /26317679 --> <div> <ul> <li><a href="#">Home <span>(current)</span></a></li> <li><a href="#">Features</a></li> <li><a href="#">Pricing</a></li> <li><a href="#">Disabled</a></li> </ul> </div> </nav>
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like