#mask {
position: absolute;
z-index: 990;
display: none;
width: 100%;
background: #000;
filter: alpha(opacity=50); /* 兼容IE9- */
-moz-opacity: 0.5;/* 兼容旧版Mozilla */
-khtml-opacity: 0.5;/* 兼容旧版Safari */
opacity: 0.5;
}
#adviceBox {
display: none;
position: absolute;
top: 260px;
width: 600px;
height: 260px;
background: #fff;
z-index:991;
}
<div id="mask"></div>
<div id="adviceBox"></div>
<button οnclick="showAdvice()">click</button>
<script type="text/javascript" src="/script/jquery-1.10.1.min.js"></script>
function showAdvice() {
$("#mask").css('height', document.body.scrollHeight);
$("#adviceBox").css('right', document.body.clientWidth / 2 - parseInt($("#adviceBox").css('width')) / 2);
$("#mask,#adviceBox").fadeToggle();
}
position: absolute;
z-index: 990;
display: none;
width: 100%;
background: #000;
filter: alpha(opacity=50); /* 兼容IE9- */
-moz-opacity: 0.5;/* 兼容旧版Mozilla */
-khtml-opacity: 0.5;/* 兼容旧版Safari */
opacity: 0.5;
}
#adviceBox {
display: none;
position: absolute;
top: 260px;
width: 600px;
height: 260px;
background: #fff;
z-index:991;
}
<div id="mask"></div>
<div id="adviceBox"></div>
<button οnclick="showAdvice()">click</button>
<script type="text/javascript" src="/script/jquery-1.10.1.min.js"></script>
function showAdvice() {
$("#mask").css('height', document.body.scrollHeight);
$("#adviceBox").css('right', document.body.clientWidth / 2 - parseInt($("#adviceBox").css('width')) / 2);
$("#mask,#adviceBox").fadeToggle();
}