Last Updated: September 09, 2019
·
443
· ms_bit

Javascript - align elements to vertical-middle

    /*
 * Vertical align to center
 */

$(document).ready(function(){

    $(".vertical-center").each( function(){
        var alturaPai = $(this).parent().height();
        var alturaElemento = $(this).height();
        var margem = (alturaPai/2) - (alturaElemento/2);
        $(this).css('margin-top', margem);
    });
});