How to create a gap above navigation bar where we place text or buttons in bootstrap 4?











up vote
0
down vote

favorite












I want to create a gap above navigation bar for echo name like: Welcome Sarah! Kindly check the image what output I am getting:



enter image description here




  1. In above image I want to echo Welcome Sarah above the Login | Sign Up buttons.

  2. I want to show search bar above the Adidad Shoe Store Starting from let-top. And welcome Sarah on the right-end. Then navigation will show.


my code:



<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<div class="container">
<div class="row float-right" >

// Search bar
<input type="text" placeholder="Search" name="search">
<a href="">Hello Sarah!</a>
</div>
</div>


<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">

<a class="navbar-brand" href="#">Adidas Shoe Store</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navb" class="navbar-collapse collapse hide">
<ul class="navbar-nav">



<li class="nav-item">
<a class="nav-link" href="#" style="color:#007bff;">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 2</a>
</li>
</ul>

<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#"><span class="fas fa-user"></span> Sign Up</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><span class="fas fa-sign-in-alt"></span> Login</a>
</li>
</ul>
</div>
</nav>









share|improve this question




























    up vote
    0
    down vote

    favorite












    I want to create a gap above navigation bar for echo name like: Welcome Sarah! Kindly check the image what output I am getting:



    enter image description here




    1. In above image I want to echo Welcome Sarah above the Login | Sign Up buttons.

    2. I want to show search bar above the Adidad Shoe Store Starting from let-top. And welcome Sarah on the right-end. Then navigation will show.


    my code:



    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

    <div class="container">
    <div class="row float-right" >

    // Search bar
    <input type="text" placeholder="Search" name="search">
    <a href="">Hello Sarah!</a>
    </div>
    </div>


    <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">

    <a class="navbar-brand" href="#">Adidas Shoe Store</a>
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
    <span class="navbar-toggler-icon"></span>
    </button>
    <div id="navb" class="navbar-collapse collapse hide">
    <ul class="navbar-nav">



    <li class="nav-item">
    <a class="nav-link" href="#" style="color:#007bff;">Home</a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#">Page 1</a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#">Page 2</a>
    </li>
    </ul>

    <ul class="nav navbar-nav ml-auto">
    <li class="nav-item">
    <a class="nav-link" href="#"><span class="fas fa-user"></span> Sign Up</a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#"><span class="fas fa-sign-in-alt"></span> Login</a>
    </li>
    </ul>
    </div>
    </nav>









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to create a gap above navigation bar for echo name like: Welcome Sarah! Kindly check the image what output I am getting:



      enter image description here




      1. In above image I want to echo Welcome Sarah above the Login | Sign Up buttons.

      2. I want to show search bar above the Adidad Shoe Store Starting from let-top. And welcome Sarah on the right-end. Then navigation will show.


      my code:



      <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

      <div class="container">
      <div class="row float-right" >

      // Search bar
      <input type="text" placeholder="Search" name="search">
      <a href="">Hello Sarah!</a>
      </div>
      </div>


      <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">

      <a class="navbar-brand" href="#">Adidas Shoe Store</a>
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div id="navb" class="navbar-collapse collapse hide">
      <ul class="navbar-nav">



      <li class="nav-item">
      <a class="nav-link" href="#" style="color:#007bff;">Home</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#">Page 1</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#">Page 2</a>
      </li>
      </ul>

      <ul class="nav navbar-nav ml-auto">
      <li class="nav-item">
      <a class="nav-link" href="#"><span class="fas fa-user"></span> Sign Up</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#"><span class="fas fa-sign-in-alt"></span> Login</a>
      </li>
      </ul>
      </div>
      </nav>









      share|improve this question















      I want to create a gap above navigation bar for echo name like: Welcome Sarah! Kindly check the image what output I am getting:



      enter image description here




      1. In above image I want to echo Welcome Sarah above the Login | Sign Up buttons.

      2. I want to show search bar above the Adidad Shoe Store Starting from let-top. And welcome Sarah on the right-end. Then navigation will show.


      my code:



      <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

      <div class="container">
      <div class="row float-right" >

      // Search bar
      <input type="text" placeholder="Search" name="search">
      <a href="">Hello Sarah!</a>
      </div>
      </div>


      <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">

      <a class="navbar-brand" href="#">Adidas Shoe Store</a>
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div id="navb" class="navbar-collapse collapse hide">
      <ul class="navbar-nav">



      <li class="nav-item">
      <a class="nav-link" href="#" style="color:#007bff;">Home</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#">Page 1</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#">Page 2</a>
      </li>
      </ul>

      <ul class="nav navbar-nav ml-auto">
      <li class="nav-item">
      <a class="nav-link" href="#"><span class="fas fa-user"></span> Sign Up</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#"><span class="fas fa-sign-in-alt"></span> Login</a>
      </li>
      </ul>
      </div>
      </nav>






      html css html5 navigation bootstrap-4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      James Z

      11.1k71735




      11.1k71735










      asked 2 days ago









      Sarah

      1426




      1426
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          This is not working as expected because Bootstrap .fixed-top class assigns z-index value of 1030 and position:fixed at top to the nav.



          As a result, the .container you added is displayed both behind and not above the nav.



          The .container needs position other than static and z-index greater than 1030 to display above the nav. Additionally, the nav needs some padding-top to make visual space for the .container contents in this scenario.



          The following structure and added CSS achieves the effect you're looking for:



          <div class="container" style="position: relative; z-index: 1031; padding: .5rem 1rem;">
          <div class="row">
          <div class="col-sm-6">
          <input type="text" placeholder="Search" name="search">
          </div>
          <div class="col-sm-6 text-right">
          <a href="">Hello Sarah!</a>
          </div>
          </div>
          </div>

          <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 2.5rem">


          (I've thrown in two .col-sm-6 divs inside your .row to make things easier to arrange on mobile resolutions; also note that .container class is of limited width unlike nav so you should change it to .container-fluid)






          share|improve this answer























          • Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
            – Sarah
            yesterday










          • Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
            – sevensky
            yesterday













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343230%2fhow-to-create-a-gap-above-navigation-bar-where-we-place-text-or-buttons-in-boots%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          This is not working as expected because Bootstrap .fixed-top class assigns z-index value of 1030 and position:fixed at top to the nav.



          As a result, the .container you added is displayed both behind and not above the nav.



          The .container needs position other than static and z-index greater than 1030 to display above the nav. Additionally, the nav needs some padding-top to make visual space for the .container contents in this scenario.



          The following structure and added CSS achieves the effect you're looking for:



          <div class="container" style="position: relative; z-index: 1031; padding: .5rem 1rem;">
          <div class="row">
          <div class="col-sm-6">
          <input type="text" placeholder="Search" name="search">
          </div>
          <div class="col-sm-6 text-right">
          <a href="">Hello Sarah!</a>
          </div>
          </div>
          </div>

          <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 2.5rem">


          (I've thrown in two .col-sm-6 divs inside your .row to make things easier to arrange on mobile resolutions; also note that .container class is of limited width unlike nav so you should change it to .container-fluid)






          share|improve this answer























          • Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
            – Sarah
            yesterday










          • Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
            – sevensky
            yesterday

















          up vote
          0
          down vote













          This is not working as expected because Bootstrap .fixed-top class assigns z-index value of 1030 and position:fixed at top to the nav.



          As a result, the .container you added is displayed both behind and not above the nav.



          The .container needs position other than static and z-index greater than 1030 to display above the nav. Additionally, the nav needs some padding-top to make visual space for the .container contents in this scenario.



          The following structure and added CSS achieves the effect you're looking for:



          <div class="container" style="position: relative; z-index: 1031; padding: .5rem 1rem;">
          <div class="row">
          <div class="col-sm-6">
          <input type="text" placeholder="Search" name="search">
          </div>
          <div class="col-sm-6 text-right">
          <a href="">Hello Sarah!</a>
          </div>
          </div>
          </div>

          <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 2.5rem">


          (I've thrown in two .col-sm-6 divs inside your .row to make things easier to arrange on mobile resolutions; also note that .container class is of limited width unlike nav so you should change it to .container-fluid)






          share|improve this answer























          • Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
            – Sarah
            yesterday










          • Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
            – sevensky
            yesterday















          up vote
          0
          down vote










          up vote
          0
          down vote









          This is not working as expected because Bootstrap .fixed-top class assigns z-index value of 1030 and position:fixed at top to the nav.



          As a result, the .container you added is displayed both behind and not above the nav.



          The .container needs position other than static and z-index greater than 1030 to display above the nav. Additionally, the nav needs some padding-top to make visual space for the .container contents in this scenario.



          The following structure and added CSS achieves the effect you're looking for:



          <div class="container" style="position: relative; z-index: 1031; padding: .5rem 1rem;">
          <div class="row">
          <div class="col-sm-6">
          <input type="text" placeholder="Search" name="search">
          </div>
          <div class="col-sm-6 text-right">
          <a href="">Hello Sarah!</a>
          </div>
          </div>
          </div>

          <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 2.5rem">


          (I've thrown in two .col-sm-6 divs inside your .row to make things easier to arrange on mobile resolutions; also note that .container class is of limited width unlike nav so you should change it to .container-fluid)






          share|improve this answer














          This is not working as expected because Bootstrap .fixed-top class assigns z-index value of 1030 and position:fixed at top to the nav.



          As a result, the .container you added is displayed both behind and not above the nav.



          The .container needs position other than static and z-index greater than 1030 to display above the nav. Additionally, the nav needs some padding-top to make visual space for the .container contents in this scenario.



          The following structure and added CSS achieves the effect you're looking for:



          <div class="container" style="position: relative; z-index: 1031; padding: .5rem 1rem;">
          <div class="row">
          <div class="col-sm-6">
          <input type="text" placeholder="Search" name="search">
          </div>
          <div class="col-sm-6 text-right">
          <a href="">Hello Sarah!</a>
          </div>
          </div>
          </div>

          <nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 2.5rem">


          (I've thrown in two .col-sm-6 divs inside your .row to make things easier to arrange on mobile resolutions; also note that .container class is of limited width unlike nav so you should change it to .container-fluid)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          sevensky

          415




          415












          • Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
            – Sarah
            yesterday










          • Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
            – sevensky
            yesterday




















          • Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
            – Sarah
            yesterday










          • Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
            – sevensky
            yesterday


















          Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
          – Sarah
          yesterday




          Thanks for the reply. Your answer just awesome. What a great explanation. I have applied your code, my navigation bar come down now but search bar and welcome sarah! are showing on the navbar now, not above the navbar. Before both are showing below the navbar.
          – Sarah
          yesterday












          Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
          – sevensky
          yesterday






          Glad to hear! Interesting - should work as expected. Take a look at this pen to figure out what's causing the issue: codepen.io/pgalor/pen/cd68b3d3af00fba26f8bc8dd3503e2c7
          – sevensky
          yesterday




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343230%2fhow-to-create-a-gap-above-navigation-bar-where-we-place-text-or-buttons-in-boots%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Paul Cézanne

          UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

          Angular material date-picker (MatDatepicker) auto completes the date on focus out