Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
Created September 13, 2012 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucklearproject/3717763 to your computer and use it in GitHub Desktop.
Save nucklearproject/3717763 to your computer and use it in GitHub Desktop.
Jquery plugin para centrar verticalmente una imagen
$.fn.vCenter = function(){
this.each(function(){
parent_height = $(this).parent().height();
image_height = $(this).height();
top_margin = (parent_height - image_height)/2;
});
return this.each(function() {
$(this).css( 'margin-top' , top_margin);
});
}
$('SOME-ID-OR-CLASS').vCenter();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment