我使用的是一个jQuery弹出窗口,只是想知道如何使框保持中心,当我改变我的浏览器窗口宽度,目前它获取页面加载中心点,并保持在当我改变宽度时该位置。页面大小变化时弹出中心框
这是我使用弹出功能代码:
//Popup dialog
function popup(message) {
// get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
// calculate the values for center alignment
var dialogLeft = (maskWidth/2) - ($('#dialog-box').width())/2;
// Set overlay to fill screen
$("#dialog-overlay").css("width","100%").fadeIn();
// Set dialogue box 80px from top and central
$('#dialog-box').css({top:80, left:dialogLeft}).fadeIn();
// display the message
//$('#dialog-message').html(message);
// Close button fades out overlay and message
$('.button').live('click',function()
{
$(this).parent().fadeOut();
$('#dialog-overlay').fadeOut();
return false;
});
}
完美地工作,正是我所追求的,非常感谢! – huddds
没问题:)。 – Timm