title: Sticking Div to Top After Scrolling Past it
body: <p>Right now, I'm able to stick the <code>div</code> to the top after it scrolls down <code>320px</code> but I wanted to know if there is another way of achieving this. Below I have my code:</p>
  
  <pre><code>jQuery(function($) {
      function fixDiv() {
          if ($(window).scrollTop() &gt; 320) { 
              $('#navwrap').css({ 'position': 'fixed', 'top': '0', 'width': '100%' }); 
          }
          else {
              $('#navwrap').css({ 'position': 'static', 'top': 'auto', 'width': '100%' });
          }
      }
      $(window).scroll(fixDiv);
      fix5iv();
  });
  </code></pre>
  
  <p>it works, but some <code>divs</code> above it will not always be the same height so I can't rely on the <code>320px</code>.  How do I get this to work without using <code>if ($(window).scrollTop() &gt; 320)</code> so I can get it to fade in at the top after the user scrolls past the <code>div #navwrap</code>?</p>