Skip to content

Instantly share code, notes, and snippets.

@sevenbest
Created November 29, 2013 15:08
Show Gist options
  • Select an option

  • Save sevenbest/7707068 to your computer and use it in GitHub Desktop.

Select an option

Save sevenbest/7707068 to your computer and use it in GitHub Desktop.
JavaScript: Vertical Align
// taken from ink eb website, our-partners pages. parent-count is a class added just to count the number of elements.
$(window).load(function () {
for (var i = $('.parent-count').length; i >= 0; i--) {
var parentHeight = $('#parent-' + i).height();
var childHeight = $('#child-' + i).height();
$('#child-' + i).css('margin-top', (parentHeight - childHeight) / 2);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment