0

Logo Centered Inside Navbar I try to achieve it using bootstrap.. But I don't want to collapse the logo part, only collapse other li.

<header role="banner">
            <nav id="navbar-primary" class="navbar" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-primary-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" id="navbar-primary-collapse">
                        <ul class="nav navbar-nav">
                            <li><a href="#"><span class="glyphicon glyphicon-home"
                             aria-hidden="true"></span> Home</a></li>
                            <li style="margin-right: 80px"><a href="articles.html"><i class="fa fa-pagelines" aria-hidden="true"></i>
                             Articles</a></li>
                            <li style="margin-left: 80px"><a href="signIn.html"><i class="fa fa-sign-in" aria-hidden="true"></i>
                             Sign in</a></li>
                            <li class="active"><a href="signUp.html"><i class="fa fa-sign-in" aria-hidden="true"></i>
                             Sign up</a></li>
                        </ul>
                    </div>
                    <div style="float:none">
                        <a href="#"><img src="../image/uoblogo.png" height="60px" width="200px" ></a>
                    </div>
                </div>
            </nav>
        </header>
zgood
  • 12,181
  • 2
  • 25
  • 26
  • Possible duplicate of [Centering brand logo in Bootstrap 3 Navbar](http://stackoverflow.com/questions/23400234/centering-brand-logo-in-bootstrap-3-navbar) – vanburen Dec 06 '16 at 23:16

2 Answers2

1

This has basically been answered on SO before. You'll need to tweak the CSS for your image height, etc.., and keep the navbar-brand out of the navbar-collapse

.navbar-brand {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    text-align: center;
    margin: auto;
}
.navbar-brand > img {
    display: initial;
}
.navbar-toggle {
    z-index:3;
}

http://www.codeply.com/go/G5uYBjmKkf

Community
  • 1
  • 1
Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
0

Move image inside the ul and apply vertical-align to each li would fix your issue

check this codepen

change your mark up to the following

<header role="banner">
  <nav id="navbar-primary" class="navbar" role="navigation">
        <ul class="nav navbar-nav">
          <li>
            <a href="#">
              <span class="glyphicon glyphicon-home icon" aria-hidden="true"></span> Home</a>           
          </li>
          <li>
            <a href="articles.html"><i class="fa fa-pagelines icon" aria-hidden="true"></i>Articles</a>
          </li>
          <li>
            <a href="signIn.html"><i class="icon fa fa-sign-in" aria-hidden="true"></i>Sign in</a>
          </li>
          <li class="img">
            <a href="#"><img src="https://lh6.googleusercontent.com/-lLR_c-yGAKc/AAAAAAAAAAI/AAAAAAAAGoY/3TnWGhgp4-0/s0-c-k-no-ns/photo.jpg" height="60px" width="200px"></a>
          </li>
          <li class="active">
            <a href="signUp.html"><i class="icon fa fa-sign-in" aria-hidden="true"></i>Sign up</a>
          </li>
        </ul>

  </nav>
</header>

and css to the following

 ul li a{
   line-height:50px!important;
  vertical-align:bottom;
}

Hope it helps

Geeky
  • 7,420
  • 2
  • 24
  • 50