title: How to dynamically change element margin-top dependent on body height
body: <p>I have a container within my body and I need to set this element to centered vertical alignment. I need to do this also dependent on body height, and change it dynamically.</p>
  
  <p>I tried with something like the below code, but it doesn't work perfectly and most importantly not dynamic. Note: I can't do this with css.</p>
  
  <pre><code>var ah = $('body').height();
  var ph = $('#main_container').parent().height();
  var mh = Math.ceil((ph-ah) / 2);
  $('#main_container').css('margin-top', mh);
  </code></pre>