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);