<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="author"content="Chomo" />
<title>全屏屏蔽、自动居中的lightBox</title>
<style type="text/css">
* { margin:0; padding:0; }
html,body { height:100%; overflow:hidden;font:12px/1.5 simsun;}
.myPage { line-height:3; overflow:auto;width:100%; height:100%;}
.lightBox,
.popupCover,
.popupIframe,
.popupComponent { position:absolute;left:0; top:0; width:100%; height:100%;}
.popupComponent { z-index:2; display:none;}
.popupIframe { display:block;_display:block; _filter:alpha(opacity=0);}
.popupCover { background:#000; opacity:0.7;*filter:alpha(opacity=70);}
.lightBox { text-align:center;overflow:auto;}
.lightBoxContent { display:inline-block;*display:inline; zoom:1; width:300px; padding:10px; background:#fff; border:5pxsolid #00b4ff; vertical-align:middle;}
.lightBoxMaxHeight { display:inline-block;vertical-align:middle; height:100%; *height:99.5%; width:1px; overflow:hidden;margin-left:-1px;}
.lightBoxWrapper { display:inline-block;*display:inline; zoom:1; text-align:left;}
.lightBoxClose { color:#f00;}
.lightBoxSubmit { margin-top:10px;padding-top:5px; border-top:1px solid #ccc;}
.lightBoxSubmit input { font-size:12px;padding:0 10px; overflow:visible; margin:0 5px;}
</style>
</head>
<body>
<div class="popupComponent"id="lightBox">
<iframe class="popupIframe"src="http://www.baidu.com"></iframe>
<div class="popupCover"></div>
<div class="lightBox"> <spanclass="lightBoxMaxHeight"></span>
<div class="lightBoxContent">
<div class="lightBoxWrapper"> 弹出的DIV<br/>
</div>
<div class="lightBoxSubmit">
<input type="button" value="确定"οnclick="hideLayer('lightBox')" />
<input type="button" value="取消"οnclick="hideLayer('lightBox')" />
</div>
</div>
</div>
</div>
<div class="myPage">
<div style="text-align:center;">
<input type="button" value="测试"οnclick="showLayer('lightBox')" />
</div>
</div>
<script>
function showLayer(id) {
document.getElementById(id).style.display = "block";
}
function hideLayer(id) {
document.getElementById(id).style.display = "none";
}
</script>
</body>
</html>
Div弹出层
最新推荐文章于 2025-04-24 14:57:53 发布