Giant Jam Sandwich schrieb:
Hey All,
The viewportCenter() plugin is now in beta, and is available here:
http://www.reindel.com/blog/src/jquery_viewport_center/
Hi Brian,
it works nice in FF2 and Opera9.1.
How about an option to use percentage values instead of pixels? That way
it would rearrange itself, when the size of the viewport is changed.
This did it for me: (does not support pixel values though)
$.fn.centerElement = function() {
return this.each(function()
{
var el = this;
$(el).wrap("<div
style='position:absolute;top:50%;left:50%;width:1px;height:1px;'></div>");
$(el).css({position: 'relative', left: el.offsetWidth / -2 + "px",
top: el.offsetHeight / -2 + "px"});
});
};
Cheers,
/rw