I have JS code that fades the background to dark and opens a white modal window, for example:
function open_litebox(link) {
var overlay_black = 'position:absolute;top:0%;left:0%;width:100%;height:100%;background:black;z-index:1001;opacity:0.5;';
$('body').append('<div style="' + overlay_black + '"></div>');
var overlay_white = 'position:absolute;top:25%;left:25%;padding:5px;background-color:white;z-index:1002;overflow:auto;';
$('body').append('<div style="' + overlay_white + '"><p>heeeyyy</p></div>');
}
But the problem is that the screen does not display a dead point. I want the modal window to be dead center both vertically and horizontally, but I don’t know what width / height of the content inside the modal window will be, so I can’t set fixed values.
Any help is appreciated.
source
share