Kenan Christian Kenan Christian - 1 year ago 160
CSS Question

Centering navbar-brand image with centered navbar

I'm just learning Bootstrap 3 and I want to use that in my website so it's still comfortable to access from mobile devices.

I want to achieve something like this:

enter image description here

but this is as far as I get.
This is the code:

.navbar-brand {
position: absolute;
width: 100%;
left: 0;
top: 0;
text-align: center;
margin: auto;

.navbar-brand:focus {
text-decoration: none;

.navbar-brand > img {
display: inline-block;

@media (min-width: 768px) {
.navbar > .container .navbar-brand,
.navbar > .container-fluid .navbar-brand {
margin-left: -15px;

.navbar .divider-vertical {
height: 50px;
margin: 0 9px;
border-right: 1px solid #ffffff;
border-left: 1px solid #f2f2f2;

.navbar-inverse .divider-vertical {
border-right-color: #222222;
border-left-color: #111111;

@media (max-width: 767px) {
.navbar-collapse .nav > .divider-vertical {
display: none;

<script src=""></script>
<script src=""></script>
<link href="" rel="stylesheet"/>

<div class="navbar navbar-default navbar-static-top">
<div class="container">
<a href="#" class="navbar-brand"><img src="image/nav_logo.png"/></a>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-left">
<li class="active"><a href="#">Home</a></li>
<li class="divider-vertical"></li>
<li><a href="#">Product</a></li>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">About</a></li>
<li class="divider-vertical"></li>
<li><a href="#">Contact</a></li>
<div class="navbar navbar-inverse navbar-fixed-bottom">
<div class = "container">
<div class="social">
<a class="pull-left icon" href="#" data-icon = "f"></a>
<a class="pull-left icon" href="#" data-icon = "i"></a>

Answer Source

Just add this to your css

.navbar-default .navbar-collapse, .navbar-default .navbar-form {
    max-width: 480px; /**change the max width to what ever you want you can add it in media query too*/
    margin: 0 auto;  /**center the menu*/

live Demo