Posted By

touffies on 12/15/10


Tagged

jquery valign


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dubogii


Vertical Align


 / Published in: jQuery
 

  1. /* ------------------------------------------------------------------
  2.   Vertically align Function ---------------------------------------- */
  3. $.fn.vAlign = function() {
  4. return this.each(function(i) {
  5. var ah = $(this).height();
  6. var ph = $(this).parent().height();
  7. var mh = (ph - ah) / 2;
  8.  
  9. $(this).css('margin-top', mh);
  10. });
  11. };

Report this snippet  

You need to login to post a comment.