div 弹出居中

var Itemindex = 0;
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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值