Vertically Align Div with using jQuery

(function ($) {
    $.fn.vAlign = function() {
        return this.each(function(i){
            var h = $(this).height();
            var p = $(this).parent().height();
            var mt = (p - h) / 2;
            $(this).css('margin-top', mt);
        });
    };
})(jQuery);
$('#example').vAlign();

Author: Raghava

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *


*

'