画面サイズを取得して中央配置する
function setCenter( ele ) {
var l = Math.floor(($(window).width() - $(ele).width()) / 2);
var t = Math.floor(($(window).height() - $(ele).height()) / 2);
$(ele).css({
"top": t,
"left": l
});
}
setCenter(".dialog");
$(window).resize(function(){
setCenter(".dialog");
});
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;
};
$("#ww10101").center();