Return to Snippet

Revision: 45270
at April 28, 2011 02:18 by xz


Initial Code
(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('padding-top', mh);
			});
		};
		
		})(jQuery);

$('.centered').vAlign();

Initial URL

                                

Initial Description

                                

Initial Title
vertical centering with jQuery

Initial Tags
center

Initial Language
jQuery