I used this jQuery script to center my div based on browsers window resolution. However I can’t get it working. What am I missing here?
I posted it in jsFiddle for better understanding here http://jsfiddle.net/9wvt3/
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
return this;
}
$(#main).center();
This:
Should probably be:
Note the
'in the$()function argument.