<script type="text/javascript">
function showDiv(){
document.getElementById('popDiv').style.display='block';
document.getElementById('bg').style.display='block';
}
function closeDiv(){
document.getElementById('popDiv').style.display='none';
document.getElementById('bg').style.display='none';
}
</script>
<div id="popDiv" style="z-index:99;display:none;position:absolute;margin-top: 20%;margin-left: 40%;background-color: #FFF;">
<h3>这里的html自己写,样式什么的自定义</h3>
<form action="#">
<p><span>账号:</span><input type="text"></p>
<p><span>密码:</span><input type="password"></p>
</form>
<br/>
<a href="javascript:closeDiv()">关闭遮罩层</a></div>
<div id="bg" style="display:none;background-color: #ccc;width: 100%;position:absolute;height: 100%;opacity: 0.5;z-index: 1;"></div>
<div style="padding-top: 10%;padding-left:40%;z-index:1;">
<input type="Submit" name="" value="打开遮罩层" onclick="javascript:showDiv()" />
</div>
效果图:
点击打开就一闪关闭了
function showDiv(){
document.getElementById('popDiv').style.display='block';
document.getElementById('bg').style.display='block';
}
function closeDiv(){
document.getElementById('popDiv').style.display='none';
document.getElementById('bg').style.display='none';
}
这里的html自己写,样式什么的自定义
账号:
密码: