/ Published in: jQuery
usage: $('div img').vAlign();
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(function ($) { // VERTICALLY ALIGN FUNCTION $.fn.vAlign = function() { return this.each(function(i){ var ah = $(this).height(); var ph = $(this).parent().height(); var mh = (ph - ah) / 2; $(this).css('margin-top', mh); }); }; })(jQuery);