Created
March 9, 2015 15:20
-
-
Save timstl/c2dc5541094e99c72ee4 to your computer and use it in GitHub Desktop.
jquery.vadjust.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
vadjust plugin. | |
adjust top margin on vertically centered elements. | |
var $vadj = $('[data-vadjust="true"]'); | |
if ($vadj.length > 0) { $vadj.vadjust(); } | |
*/ | |
;(function($) { | |
$.fn.vadjust = function(options) | |
{ | |
this.each(function() { | |
var $this = $(this), | |
mgn = (parseFloat($this.height()) / 2) * -1; | |
$this.css('margin-top', mgn + "px"); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment