Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a header image before navbar-fixed-top

How do I add a header image so that it will appear on top of a navbar-fixed-top. And as the user scrolls down the navbar will stick to the top?

I have tried adding it to a container but it does not work as expected.

Here is my code so far.

<body>
 <header>
  <img src="header/1024x100.png">
 </header>
 <div class="container-fluid">
  <div class="navbar navbar-inverse navbar-fixed-top">
   <div class="navbar-inner">
    <div class="container-fluid">
      <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="#"></a>
      <div class="nav-collapse collapse">
        <p class="navbar-text pull-right">
          Logged in as <a href="#" class="navbar-link">Username</a>
        </p>
        <ul class="nav">
          <li class="active"><a href="#">Home</a></li>
          <li><a href="#about">About</a></li>
          <li><a href="#contact">Contact</a></li>
        </ul>
      </div><!--/.nav-collapse -->
    </div>
  </div>
</div>

Thanks.

like image 364
John Doe Avatar asked Feb 27 '13 05:02

John Doe


People also ask

How do I add a picture to navigation bar?

We just need to add a div tag with the class as a container and put the navbar-brand(image or logo) inside this div. After that, we just need to add the class mx-auto to the navbar-brand class.

How do I fix the logo on my navigation bar?

Your navigation is overlapping your logo making it so you can't click it. Use z-index to move the logo on top of the navigation. Then change the width of the outer div to a set value so it doesn't overlap the navigation. This is correct.

What is navbar fixed top?

A fixed navigation bar, also referred to as a “sticky” navigation bar, is a toolbar that stays in place while the user is scrolling the web page.


1 Answers

JsFiddle with scrolling nav check link

Note: Incase your image is smaller than screen size,insert this snippet inside your css

.masthead img{
width:100%;
 }

The html should look like the following :

<div class="masthead">
<img src="http://placehold.it/940x150"/>
</div>
<!-- /container -->
<div class="navbar affix-top" data-spy="affix" data-offset-top="150">
<div class="navbar-inner">
    <div class="container">
               <ul class="nav">
        <li class="active"><a href="#">Home</a>

        </li>
        <li><a href="#">Link</a>

        </li>
        <li><a href="#">Link</a>

        </li>
    </ul>
    </div>
   </div>
 </div>
 <!-- navbar -->
<div class="container">
  <div class="row-fluid">
    <div class="span4">
    content goes here 
    </div>
   </div>
 </div>
like image 56
Shail Avatar answered Sep 24 '22 01:09

Shail