html - Image on bootstrap navbar to stick out above and below menu bar -


how can make bootstrap navbar that: navbar

the image should centered on navbar.

here have currently:

<div class="navbar navbar-static-top">     <div class="navbar-inner">          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">             <span class="icon-bar"></span>             <span class="icon-bar"></span>             <span class="icon-bar"></span>         </a>         <a class="brand" href="index.html">             <img style="height:50px;" src="http://kpv.s3.amazonaws.com/static/img/logo.jpg">         </a>         <div class="nav-collapse collapse">             <ul class="nav pull-left">                 <li class="active">                     <a href="index.html" class="scroller">home</a>                 </li>                 <li>                     <a href="pricing.html" class="scroller">pricing</a>                 </li>                 <li>                     <a href="knowledge.html" class="scroller">faq</a>                 </li>             </ul>         </div> 

this css accompanies above code:

.navbar-inner{     position:relative;     padding-left:70px; }  .navbar .brand {     margin-left: 0px;     font-size: 20px;     font-weight: 200;     color: #777777;     text-shadow: 0 1px 0 #ffffff;     position: absolute;     width: 50px;     background: #f00;     left: 0px;     top: 0px;     padding: 10px; } 

that's new code: http://www.bootply.com/geon0zj3e8

how can make image centered?

here's 1 way can using position:absolute place image. depending on plan on doing mobile, you'll have adjust navbar according (the example assumes default bootstrap behavior).

working example:

nav.navbar {    margin-top: 50px;    margin-bottom: 65px;    border: 0;  }  nav.navbar .navbar-collapse {    border: 0;  }  nav.navbar .navbar-brand {    position: absolute;    width: 50px;    height: 50px;    left: 50%;    top: -50px;    transform: translatex(-50%);    padding: 0px;  }  nav.navbar .navbar-brand img {    height: 150px;    width: 150px;    margin-left: -50px;  }  @media screen , (min-width: 768px) {    nav.navbar {      margin-top: 65px;      margin-bottom: 80px;      min-height: 20px;      height: 20px;    }    nav.navbar .navbar-nav > li > {      font-size: 12px;      padding: 0px 10px;    }    nav.navbar .navbar-brand {      top: -65px;    }  }  @media screen , (max-width: 767px) {    nav.navbar .navbar-nav {      margin-top: 50px;    }  }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />    <nav class="navbar navbar-inverse navbar-static-top">    <div class="container">        <div class="navbar-header">        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">          <span class="icon-bar"></span>          <span class="icon-bar"></span>          <span class="icon-bar"></span>        </button>        <a class="navbar-brand" href="#">          <img src="http://placehold.it/150x150/b71c1c/fff?text=logo">        </a>      </div>        <div class="collapse navbar-collapse" id="navbar">        <ul class="nav navbar-nav">          <li class="active"><a href="index.html" class="scroller">home</a>          </li>          <li><a href="pricing.html" class="scroller">pricing</a>          </li>          <li><a href="knowledge.html" class="scroller">faq</a>          </li>        </ul>      </div>      </div>  </nav>    <div class="container">    <div class="alert alert-info">      content    </div>  </div>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -