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);
});
});
Written by ms_bit
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#