Created
December 7, 2013 14:10
-
-
Save ahmad24/7842130 to your computer and use it in GitHub Desktop.
jQuery : scheleton plugin
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
(function($){ | |
$.fn.center = function(){ | |
var element = this; | |
$(element).load(function(){ | |
changeCss(); | |
$(window).bind("resize", function(){ | |
changeCss(); | |
}); | |
function changeCss(){ | |
var imageHeight = $(element).height(); | |
var imageWidth = $(element).width(); | |
var windowWidth = $(window).width(); | |
var windowHeight = $(window).height(); | |
$(element).css({ | |
"position" : "absolute", | |
"left" : windowWidth / 2 - imageWidth / 2, | |
"top" : windowHeight /2 - imageHeight / 2 | |
}); | |
}; | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment