title: Centering a div vertically & horizontally using jQuery
body: <p>I am using this script to center my div horizontally and vertically. </p>
  
  <p>When the page loads the div gets centered vertically, not horizontally until I resize the browser. </p>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>$(document).ready(function (){
      $(window).resize(function (){
          $('.className').css({
              position:'absolute',
              left: ($(window).width() - $('.className').outerWidth())/2,
              top: ($(window).height() - $('.className').outerHeight())/2
          });
      });
      $(window).resize();
  });
  </code></pre>