Vertical align any element using jQuery
$(function() {
$('element').each( function( index, item) {
var parent = $(item).parent();
var $this = $(item);
parent.css('position', 'relative');
$this.css('position', 'absolute').css('top', Math.round((parent.height() - $this.outerHeight()) / 2) + 'px');
});
});
Written by Pascal Gerritsen
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#