这是我到目前为止所拥有的
函数 modalThree($type) { var $type;
jQuery("#simplemodal-container").animate({ width: 250 }, 0);
jQuery("#simplemodal-container").animate({"left": "+=200px"}, "fast");
jQuery("#simplemodal-container").animate({"top": "-=50px"}, "fast");
jQuery('#simplemodal-container').css({
position:'absolute',
left: (jQuery(window).width() - jQuery('#simplemodal-container').outerWidth())/2,
top: (jQuery(window).height() - jQuery('#simplemodal-container').outerHeight())/2
});
jQuery("#dialog").load("/default/modalTwo", function()
{
jQuery("#dialog").modal({
overlay:80,
autoResize:true,
overlayCss: {backgroundColor:"#000"}
});
});
}
我的网站几乎是一个固定宽度,我知道来自 ajax 调用的内容的大小。
我使用以下方法调整它的大小
jQuery("#simplemodal-container").animate({ width: 250 }, 0); jQuery("#simplemodal-container").animate({"left": "+=200px"}, "fast"); jQuery("#simplemodal-container").animate({"top": "-=50px"}, "fast");
它有点工作,但我想根据窗口大小计算左边和顶部有多少。
它有效,但我不确定它是否是解决方案。