Navbar to overlay background and image color

Question 1: I want the navbar overlay to overlay on top of the background color and the background div ( top-banner ) as I scroll down. the background color will overlap my navigation affix instead.

How do I get my navbar to be on top of my background for the top level of the div banner.

There is another problem, which is my navbar which has a marker left on itself, when I was adding the spy data binding, the navbar shifts slightly to the right causing a space on the left, and when I scale the screen down to a smaller device size, the nav collapse menu forbidden unless I slightly flicked to the right and then switched to the menu. I'm not sure why the affix got such problems. How to fix it.

THANKS FOR HELP for solving these problems!

Below is my code

    <html>
    <head>
    <title>Demo</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
    .navbar-header,
    .navbar-brand {
        line-height: 100px;
        height: 100px;
        padding-top: 0;
    }
    .affix .navbar-default {
        position: fixed !important;
        top: 0 !important;
        width: 100% !important;
        background-color: #957595 !important;
    }
    .affix {
        width: 100% !important;
    }
    @media screen and (min-width: 768px) {
    .navbar-header {
        padding-left: 200px;
        text-align: center;
    }
    }
.top-banner{
    background-color: #b0c4de;
    background-image: url("bi-uk-office7-2.jpg");
    background-repeat: no-repeat;
    background-position: right top;
}
    </style>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    </head>
    <body>
    <div class="container-fluid">
            <!-- Static navbar -->
         <div id="nav" data-spy="affix">
          <nav class="navbar navbar-default" style="background-color:black;background: rgba(0,0,0,0.9);">
            <div class="container-fluid">
              <div class="navbar-header header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Logo</a>
              </div>
              <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                  <li><a href="#"><font color="white">Link 1</font></a></li>
                  <li><a href="/list"><font color="white">Link 2</font></a></li>
                  <li><a href="/list"><font color="white">Link 3</font></a></li>
              </div><!--/.nav-collapse -->

   </div>
      </nav>
</div>

<section>
<div class="col-xs-12">

<div class="top-banner">
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
Hello world<br/>
<hr>
</div>

</div>
</section>



</div>
</body>
</html>

      

+3


source to share


1 answer


Add z-index

to yours #nav

like below and add a property margin-left

on top of that to stay at the far left as it gets padding from its parentcontainer-fluid



#nav
{
     z-index:1000;
     margin-left: -15px;
}

      

+3


source







All Articles