日期:2014-05-16 浏览次数:20306 次
lightbox效果,获取视窗的宽和高,半透明层设置为视窗的高/宽,设置透明样式,浮动层那个自己计算为准,设置为absolute
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style>
.alpha{position:absolute;z-index:10;left:0px;top:0px;filter:alpha(opacity=50);opacity:.5;background:#000000;}
</style>
<script>
window.onload = function () {
var backCompat = document.compatMode == 'BackCompat';
var w = backCompat ? document.body.scrollWidth : document.documentElement.scrollWidth
, h = backCompat ? Math.max(document.body.clientHeight, document.body.scrollHeight) : document.documentElement.scrollHeight;
var div = document.createElement('div');
div.className = 'alpha';
div.id = 'lightbox';
div.style.width = w + 'px';
div.style.height = h + 'px';
document.body.appendChild(div)
}
</script>
底层内容
.bg{
background-color: rgba(0,0,0,.5);
filter:progid:DXImageTransform.Microsoft.gradient(startcolorstr=#88000000,endcolorstr=#88000000e);
}