title: How to make a navbar fixed in html and css?
body: <p>I am designing a website and i would like to have the navbar fixed on my page so that you dont have to scroll all the way back up to navigate the website. I know how to do this using for example <code>position: fixed;</code> etc however cannot find a working solution</p>
  <p>index.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Home&lt;/title&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://use.fontawesome.com/releases/v5.6.1/css/all.css&quot;&gt;
  &lt;link rel='shorcut icon' type='image/x-icon' href='circle.ico' /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;title&gt;Home&lt;/title&gt;
  
  &lt;div class=&quot;header&quot;&gt;
    &lt;h3 class=&quot;logo&quot; id='logo'&gt;Name&lt;/h3&gt;
    &lt;input type=&quot;checkbox&quot; id=&quot;chk&quot;&gt;
    &lt;label for=&quot;chk&quot; class=&quot;show-menu-btn&quot;&gt;
      &lt;i class=&quot;fas fa-ellipsis-h&quot;&gt;&lt;/i&gt;
    &lt;/label&gt;
  
    &lt;ul class=&quot;menu&quot; id='navbar'&gt;
      &lt;a href=&quot;#section1&quot;&gt;Home&lt;/a&gt;
      &lt;a href=&quot;#section2&quot;&gt;About&lt;/a&gt;
      &lt;a href=&quot;#&quot;&gt;Calendar&lt;/a&gt;
      &lt;a href=&quot;#&quot;&gt;News&lt;/a&gt;
      &lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;
      &lt;label for=&quot;chk&quot; class=&quot;hide-menu-btn&quot;&gt;
        &lt;i class=&quot;fas fa-times&quot;&gt;&lt;/i&gt;
      &lt;/label&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>style.css:</p>
  <pre><code>body {
    background-image: url('img5.jpg');
    background-repeat: no-repeat;
  }
  
  *{
    margin: 0;
    padding: 0;
    font-family: &quot;montserrat&quot;,sans-serif;
  }
  .header{
    height: 100px;
    background: #34495e;
    padding: 0 20px;
    color: #fff;
  }
  .logo{
    line-height: 100px;
    float: left;
    text-transform: uppercase;
  }
  
  .menu{
    float: right;
    line-height: 100px;
  }
  .menu a{
    color: #fff;
    text-transform: uppercase;
    text-decoration: none;
    padding: 0 10px;
    transition: 0.4s;
  }
  .show-menu-btn,.hide-menu-btn{
    transition: 0.4s;
    font-size: 30px;
    cursor: pointer;
    display: none;
  }
  .show-menu-btn{
    float: right;
  }
  .show-menu-btn i{
    line-height: 100px;
  }
  .menu a:hover,
  .show-menu-btn:hover,
  .hide-menu-btn:hover{
    color: #3498db;
  }
  
  #chk{
    position: absolute;
    visibility: hidden;
    z-index: -1111;
  }
  
  .content{
    padding: 0 20px;
  }
  .content img{
    width: 100%;
    max-width: 700px;
    margin: 20px 0;
  }
  .content p{
    text-align: justify;
  }
  
  @media screen and (max-width:800px) {
    .show-menu-btn,.hide-menu-btn{
      display: block;
    }
    .menu{
      position: fixed;
      width: 100%;
      height: 100vh;
      background: #333;
      right: -100%;
      top: 0;
      text-align: center;
      padding: 80px 0;
      line-height: normal;
      transition: 0.7s;
    }
    .menu a{
      display: block;
      padding: 20px;
    }
    .hide-menu-btn{
      position: absolute;
      top: 40px;
      right: 40px;
    }
    #chk:checked ~ .menu{
      right: 0;
    }
  }
  
  .card {
    box-shadow: 0 4px 16px 0 rgba(0,0,0,0.2);
    transition: 0.3s;
    width: 100%;
  }
  
  .container {
    padding: 2px 16px;
  }
  p {
    font-size: 120%;
  }
  
  h4 {
    font-size: 130%;
  }
  
  </code></pre>
  <p>Things i have tried:</p>
  <pre><code>.menu {
    overflow: hidden;
    position: fixed;
    top: 0;
    width: 100%;
  }
  
  .menu {
    position: fixed;
    right: 0;
    left: 0;
    top: 0;
    z-index: 1030;
  }
  </code></pre>
  <p>Any help would be greatly appreciated!</p>
  <p>Thankyou!!! :D</p>