Bootstrap 3: How To Make A Centered Navbar
Answer :
This should be exactly what you are looking for.
Here is a jsFiddle Demo
If you want this as a fixed-footer, just add navbar-fixed-bottom
class to the <nav class="navbar navbar-default" role="navigation">
element.
HTML
<nav class="navbar navbar-default" role="navigation"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> </div> </nav>
CSS
@media (min-width: 768px){ .navbar-nav{ float:none; margin: 0 auto; display: table; table-layout: fixed; } }
.nav.navbar-nav { display: flex; justify-content: center; flex-wrap: wrap; } @media (min-width: 768px) { .navbar-nav { float: none; } }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> <nav class="navbar navbar-default"> <div class="container-fluid"> <ul class="nav navbar-nav"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Help</a></li> </ul> </div> </nav>
#menu-main{ width: 100%; text-align: center; display:block; } #menu-main li { display: inline-block; float: none; vertical-align: top; } #menu-main a{ display: block; padding: 10px; }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="footer row"> <div class="col-12"> <ul id="menu-main" class="nav navbar-nav"> <li> <a href="#">Home</a> </li> <li> <a href="#">About</a> </li> <li> <a href="#">Help</a> </li> </ul> </div> </div>
Comments
Post a Comment