views:

846

answers:

2

Hi,

I'm using a script that greys out the background with a #mask element and centers my .memError message on the screen. The problem is that my site styles both the body and the html elements-- body is fixed-width and centered within the html element. When I use the script below, the #mask and .memError message are both positioned relative to the body element. How can I position them relative to html instead?

//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();

//Set heigth and width to mask to fill up the whole screen
$('#mask').css({
    'width': maskWidth,
    'height': maskHeight
});

//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("normal", 0.9);

//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();

//Set the popup window to center
$('.memError').css('top', winH / 2 - $('.memError').height() / 2);
$('.memError').css('left', winW / 2 - $('.memError').width() / 2);
+2  A: 

Why not use jmodal or another jquery plugin that builds a modal dialog for you?

Jikhan
yup, why re-invent the already well turned wheel
redsquare
+1  A: 

have you set top & left position to zero?

$('#mask').css({
 'width': maskWidth,
 'height': maskHeight,
 'left': 0,
 'top': 0
});

but, why don't you give blockUI plugin a try?

Anwar Chandra