日期:2014-05-17  浏览次数:20571 次

关于弹出层,黑色背景
.black_overlay{ display: block; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:9998; -moz-opacity: 0.8; opacity: 0.80; filter: alpha(opacity=80); }  

这是网上很通用的弹出层黑色背景样式,但,如果网页很宽,很长,或者宽度、长度,不定
width: 100%; 不能满足要求。比如网页很宽,用户拖动鼠标往右,一点弹出,弹出的只遮住了左边100%的网页,而右边新拖出来的,没有被遮住。

也不想 width: 99999px这样,指定一个很大的范围,因为滚动条的长度会变,本来网页没有那么宽。

我要遮住的是个GridView,可不可以按GridView所在的div的宽度指定它的宽度呢?

------解决方案--------------------
document.getElementById('fade').style.height
= document.documentElement.clientHeight + document.documentElement.scrollTop + 'px';
------解决方案--------------------
JScript code
var isStrict='CSS1Compat'==document.compatMode,el=isStrict?'documentElement':'body';
var w=document[el].scrollWidth,h=document[el].scrollHeight;

alert(w+'\n'+h);//w和h为你页面宽和高