Home › Forums › CSS › CSS Centering Images help › Re: CSS Centering Images help
May 20, 2012 at 9:19 pm
#103160
chrisburton
Participant
@joshuanhibbert Thanks. Too bad I need a jQuery solution.
I found this
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;
}
// Now we can just write:
$(element).center();
Solved: Result