/ Published in: jQuery
Expand |
Embed | Plain Text
jQuery.fn.center = function() { this.css("position", "absolute"); this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px"); this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px"); return this };
Comments
Subscribe to comments
You need to login to post a comment.

It can be easily done by CSS:
centered{
You are rignt kristapsancans, but this also means that parts of the content are invisible, if the width of the browser window is smaller than the content-width. And you can NOT scroll to the left to see the hidden content...
Thanks for sharing this source! vi da