title: CSS / jQuery Vertically and Horizontally Center DIV
body: <p>I'm trying to vertically and horizontally center this div even when there is content to scroll and the user is scrolling down the page.  The following test works fine in IE, but in Firefox I get a weird flickering affect when hovering over the thumbnail image.  Any thoughts?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;aj&lt;/title&gt;
  
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
      $(function() {
          // img preview
          $('.img').hover(function() {
  
              if (!$('#overlay').length) {
  
                  $('&lt;div id="overlay"/&gt;').css({
                      position: 'fixed',
                      top: 0,
                      left: 0,
                      width: '100%',
                      zIndex: 100,
                      height: $(window).height() + 'px'
                  }).appendTo('body');
  
                  $('&lt;div id="item" /&gt;').css({
                      border: '7px solid #999',
                      height: '500px',
                      width: '500px',
                      top: '50%',
                      left: '50%',
                      position: 'absolute',
                      marginTop: '-250px',
                      marginLeft: '-250px'
                  }).append('&lt;img src="' + $(this).attr('rel') + '" alt="img" /&gt;').appendTo('#overlay');
              }
          }, function() {
  
              $('#overlay').remove();
          });
      });
  
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;img class="img" src="http://ajondeck.net/temp/paperboy_thumb.gif"    rel="http://ajondeck.net/temp/paperboy.gif"
      alt="image" /&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>