title: How to center fixed navbar in another div?
body: <p>I am trying to have a fixed and centered navbar div which is within another div that's using a parallax effect. If I set the position to relative, the navbar will be centered within the other div however setting it to fixed will have a fixed navbar but not centered. I would like to avoid using margin left x amount of px because it doesn't seem consistent for cross resolutions. Is there anyway to keep the navbar fixed position but have it centered within the other div without mar?</p>
  
  <p>This is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#page-wrap {
    position: relative;
    min-width: 1366px;
    max-width: 2048px;
    margin: 0px auto;
    width: 95%;
  }
  
  header {
    background: url('../images/cover1.jpg') no-repeat;
    background-size: 100% 90%;
    width: 100%;
    height: 1000px;
  }
  
  #nav {
    background: #f0f;
    margin: 0 auto;
    height: 500px;
    min-width: 980px;
    max-width: 2048px;
    position: fixed;
    opacity: 1;
  }
  
  #main {
    background: #fff;
    position: relative;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="page-wrap"&gt;
    &lt;header&gt;
      &lt;nav id="nav"&gt;Nav&lt;/nav&gt;
    &lt;/header&gt;
    &lt;div id="main"&gt;Lorem ipsum flash.&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
    $(document).on('scroll', function(e) {
      $('#nav').css('opacity', ($(document).scrollTop() / 500));
      var st = $(window).scrollTop();
  
      $('header').css({
        'background-position-y': 0 + (st * .77) + "px"
      });
    });
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>