遮罩层代码

css
.mask{
	position: absolute;
	top: 0px;
	background-color: #000000;
	z-index: 1000;
	left: 0px;
	filter: alpha(opacity=60);
	opacity: 0.5;
	-moz-opacity: 0.5;
	display: none;
}
html
<div id="mask" class="mask"></div>
js
function show(){
		mask.style.height = screen.height+"px";
		mask.style.width = screen.width+"px";
		mask.style.display = "block";
	}
	function hide(){
		mask.style.display = "none";
	}

  jquery版本

css
.mask {       
            position: absolute; top: 0px; filter: alpha(opacity=60); background-color: #777;     
            z-index: 1002; left: 0px;     
            opacity:0.5; -moz-opacity:0.5;     
        }   
html
<div id="mask" class="mask"></div>  

js
   //兼容火狐、IE8   
    //显示遮罩层    
    function showMask(){     
        $("#mask").css("height",$(document).height());     
        $("#mask").css("width",$(document).width());     
        $("#mask").show();     
    }  
    //隐藏遮罩层  
    function hideMask(){     
          
        $("#mask").hide();     
    }  

  

posted @ 2016-11-03 01:01  仁波切  阅读(823)  评论(0编辑  收藏  举报