我使用的是一個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