function showDiv() {
var promp = document.getElementById('prompt');
var prompt_bg = document.getElementById('prompt_bg');
promp.style.left = (document.body.clientWidth -promp.offsetWidth)/2+"px";
promp.style.top = (document.body.clientHeight -promp.offsetHeight)/2+"px";
prompt_bg.style.left = (document.body.clientWidth -prompt_bg.offsetWidth)/2+"px";
prompt_bg.style.top = (document.body.clientHeight -prompt_bg.offsetHeight)/2+"px";
promp.style.display = 'block';
prompt_bg.style.display = 'block';
document.getElementById('bg').style.display = 'block';
}
function closeDiv() {
document.getElementById('prompt').style.display = 'none';
document.getElementById('bg').style.display = 'none';
document.getElementById('prompt_bg').style.display = 'none';
}
.mydiv
{
text-align: center;
z-index: 99;
width:80%;
height:40%;
position: absolute;
}
.bg
{
background-color: #666;
width: 100%;
height: 100%;
left: 0;
top: 0;
filter: alpha(opacity=50);
opacity: 0.5;
z-index: 1;
position: absolute;
}
.prompt
{
background-color: #666;
width: 84%;
height: 44%;
left: 0;
top: 0;
filter: alpha(opacity=50);
opacity: 0.5;
z-index: 1;
position: absolute;
display: none;
}
<div id="prompt" class="mydiv" style="display: none;background-color: #FFFFF;background:url(imgs/alertBg.jpg) repeat">
<div style="border-bottom:1px solid #CCCCCC;">
<div style="position:absolute;margin-left:225px;margin-right:0px;margin-top:5px;cursor:pointer;" onclick="closeDiv();">
<img src="imgs/alertClose.jpg" style="wdth:30px;height:25px;"/>
</div>
<div style="font-family:'微软雅黑','黑体','宋体'; font-weight:bold;font-size:15px;padding:10px;text-align:left;">温馨提示</div>
</div>
<div style="margin-top:20px;">
<div style="position:absolute;margin-left:40px;margin-top:10px;">
<img src="imgs/textAlert.jpg" style="width:50px;height:50px;">
</div>
</div>
<div style="margin-left:25px;margin-top:40px;margin-bottom:0px;">
<div style="font-family:'微软雅黑','黑体','宋体'; font-weight:bold;font-size:20px;color:#FF6600;margin-left:65px;text-align:left;">预约成功</div>
<div style="font-family:'微软雅黑','黑体','宋体'; font-size:15px;padding:0px;color:#FF6600;margin-left:65px;text-align:left;">稍后我们的坐席将会与您联系。</div>
</div>
</div>
<div id="prompt_bg" class="prompt"></div>
<div id="bg" class="bg" style="display: none;"></div>