How to display a navbar from a particular section of the page?

Asked

Viewed 488 times

0

In the project I’m doing, when the viewport is less than 767px it will display a menu/navbar however, it should only be displayed after a certain section of the page.

I made an example in Fiddle, there is better explained.

Section 1 - Does not display

Section 2 (Onwards) - Displays.

Example

HTML:

<nav class="navbar navbar-default navbar-fixed-bottom visible-xs">   <div class="container-fluid"> 

    <div class="navbar-header">
         <!-- <a class="navbar-brand" href="#">LOGO PSTCH</a> </div> -->


    <div class="collapse navbar-collapse visible-xs" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
       <li><a  href="#" data-toggle="modal" data-target="#myModal1" data-direction="bottom"> About</a></li>
       <li><a  href="#" data-toggle="modal" data-target="#myModal2" data-direction='bottom'> Sobre </a></li>
       <li><a  href="#" data-toggle="modal" data-target="#myModal3" data-direction='bottom'> Contact </a></li>


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

 <div id="logo"> 

            <center>
                            <a href="#desce" class="page-scroll  btn btn-xl">SECTION 1</a>
            </center>   </div>

  <div id="content">

    <p> SECTION 2  </p>

      <p> The navbar will appear here down/hereafter!</p>   </div>

CSS:

    html, body {
    height:100%;
    padding:0;
    margin:0;

}






#logo{
            background: black;
            width: 100%;
            height: 100%;          


}

#content {
        border: 1px solid black;
        width: 100%;
        height: 50%;
}

.navbar .nav  li{
    float:none;
    display:inline-block;
    *display:inline; /* Internet Explorer 7 compatibility */
    *zoom:1;
    vertical-align: bottom;

}


.navbar .navbar-collapse {
  text-align: center;
}
  • Do you want the navbar to track the user’s scroll or it to be fixed at the beginning of the white area there? I couldn’t understand.

  • Fixed on the footer. Exactly as it is there. What I want is that: When the user is in Section 1 (box with black background) the navbar is hidden! If I leave Section 1 and go to Section 2, the navbar should appear.. and so on, you understand?

1 answer

0

Maybe you can apply a margin of 100vh ( 100vh = All screen ). Vh divides your screen into 100 parts, if you put margin-top: 100vh, it will catch the entire screen, regardless of resolution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.