这个功能是怎么实现的,就是弹出一个div信息窗,然后后边的变暗 弹出信息窗我会,但是不知道怎么让后边的主内容变暗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 变暗也是一个黑色的div,在这个div上设置透明度就可以了设置透明度的css代码如下:filter:alpha(opacity=70);-moz-opacity:0.70;-khtml-opacity: 0.7;opacity:0.7; $("#id").animate({"opacity":"0.5"},3000); 搞个稍微全的demo,我也想学习一下 /***************************************************************** 弹出div遮住页面 tag 为true时则遮住页面,为false时则隐藏div,默认为true Message 用户显示的信息 ******************************************************************/function ToCover(tag,Message){ var div = document.getElementById("lm_ToCover"); var subDiv = document.getElementById("lm_ToCover_Message"); if( !!!div ){ div = document.createElement("div"); } else{ if(tag == false) { div.style.display = "none"; subDiv.style.display = "none"; } else { div.style.display = "block"; subDiv.style.display = "block"; subDiv.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight * 0.4)) + "px"; subDiv.style.left = (findDimensions().width/2-150) + "px"; div.style.width = document.body.clientWidth; div.style.height = document.body.clientHeight; div.childNodes[0].style.width = document.body.clientWidth; div.childNodes[0].style.height = document.body.clientHeight; } subDiv.innerHTML = !!Message?Message:"正在加载数据,请稍候..."; return; } div.id = "lm_ToCover"; div.style.display = "block"; div.style.backgroundColor = "black"; div.style.filter = "alpha(opacity=30)";// ie div.style.opacity = 0.3; //ff div.style.position = "absolute"; div.style.left = "0px"; div.style.top = "0px"; div.style.textAlign = "center"; div.style.marggin = "auto"; div.style.zIndex = 99; //Begin 解决ie6 select bug var iframe = document.createElement("iframe"); iframe.style.position = "absolute"; iframe.style.zIndex = 97; iframe.style.filter = "alpha(opacity=30)";//ie iframe.style.opacity = 0.3; //ff iframe.style.left = "0px"; iframe.style.top = "0px"; //End 解决ie6 select bug subDiv = document.createElement("div"); subDiv.id = "lm_ToCover_Message"; subDiv.style.position = "absolute"; subDiv.style.left = (document.documentElement.clientWidth/2) + "px"; subDiv.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight * 0.4)) + "px";; subDiv.style.fontSize = "14px"; subDiv.style.fontWeight = "bold"; subDiv.style.border = "2px white solid"; subDiv.style.backgroundColor = "#6495ed"; subDiv.style.color = "white"; subDiv.style.width = "300px"; subDiv.style.padding = "10px"; subDiv.style.textAlign = "center"; subDiv.style.lineHeight = "20px"; subDiv.style.zIndex = 100; subDiv.innerHTML = !!Message?Message:"正在加载数据,请稍候..."; div.appendChild( iframe ); document.body.appendChild( subDiv ); document.body.appendChild( div ); div.style.width = document.body.clientWidth; div.style.height = document.body.clientHeight; iframe.style.width = document.body.clientWidth; iframe.style.height = document.body.clientHeight;}根据自己需要更改 <style> .cover { width:100%; height:100%; z-index:10; position:absolute; background:black; filter:alpha(opacity=30); } </style> <center> <div id="div1" style="position:absolute;top:100px;background:white; z-index:11;display:none"> 还原就点还原按钮<BR> <INPUT TYPE="button" VALUE="还原" ONCLICK="fun('clear')" style="width:50px;height:50px"> </div> </center> <div class="cover" id="covD" style="display:none"></div> <INPUT TYPE="button" VALUE="弹出" ONCLICK="fun('cov')"> <div style="width:50;height:50;word-wrap:no-wrap;overflow:hidden;text-overflow:ellipsis;">111111111111111111111111111111111111111111111111111111111</div><SCRIPT LANGUAGE="JavaScript"><!-- function fun(stat){ if (stat == "cov") { document.getElementById("covD").style.display = ""; document.getElementById("div1").style.display = ""; } else { document.getElementById("covD").style.display = "none"; document.getElementById("div1").style.display = "none"; } }//--></SCRIPT> 总体思路用一个div,left:0px,top:0px,width:屏幕宽,height:屏幕长罩在页面上,并把背景设置成黑色。然后设置透明.再用一个div,就是你做的消息框,盖在遮罩层上。就完成了 这个主要还是要设置背景或滤镜效果filteralphaopacity javascript如何实现一个table中的增行(空白行,没有内容的) 想实现当前页面分类刷新,怎么弄 能在同一时间生成两个cookie吗 动态下拉框的实现 跪求高人指点一下 JWChat 接收消息的原理. 两个超简单的问题---急 HTML可输入编辑的下拉选择框怎么做?? 如何通过javascript将页面自动转移到另一个页面 能触发一个函数使得radio 的disabled=true或者readonly吗? 一个很急问题,大家快帮帮忙,在线给分 请教高手!关于使用DOM改变文档颜色。 如何制作网页视频播放器
设置透明度的css代码如下:
filter:alpha(opacity=70);
-moz-opacity:0.70;
-khtml-opacity: 0.7;
opacity:0.7;
$("#id").animate({"opacity":"0.5"},3000);
/***************************************************************** 弹出div遮住页面
tag 为true时则遮住页面,为false时则隐藏div,默认为true
Message 用户显示的信息
******************************************************************/
function ToCover(tag,Message)
{
var div = document.getElementById("lm_ToCover");
var subDiv = document.getElementById("lm_ToCover_Message");
if( !!!div ){
div = document.createElement("div");
}
else{
if(tag == false)
{
div.style.display = "none";
subDiv.style.display = "none";
}
else
{
div.style.display = "block";
subDiv.style.display = "block";
subDiv.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight * 0.4)) + "px";
subDiv.style.left = (findDimensions().width/2-150) + "px";
div.style.width = document.body.clientWidth;
div.style.height = document.body.clientHeight;
div.childNodes[0].style.width = document.body.clientWidth;
div.childNodes[0].style.height = document.body.clientHeight;
}
subDiv.innerHTML = !!Message?Message:"正在加载数据,请稍候...";
return;
} div.id = "lm_ToCover";
div.style.display = "block";
div.style.backgroundColor = "black";
div.style.filter = "alpha(opacity=30)";// ie
div.style.opacity = 0.3; //ff
div.style.position = "absolute";
div.style.left = "0px";
div.style.top = "0px";
div.style.textAlign = "center";
div.style.marggin = "auto";
div.style.zIndex = 99;
//Begin 解决ie6 select bug
var iframe = document.createElement("iframe");
iframe.style.position = "absolute";
iframe.style.zIndex = 97;
iframe.style.filter = "alpha(opacity=30)";//ie
iframe.style.opacity = 0.3; //ff
iframe.style.left = "0px";
iframe.style.top = "0px";
//End 解决ie6 select bug
subDiv = document.createElement("div");
subDiv.id = "lm_ToCover_Message";
subDiv.style.position = "absolute";
subDiv.style.left = (document.documentElement.clientWidth/2) + "px";
subDiv.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight * 0.4)) + "px";;
subDiv.style.fontSize = "14px";
subDiv.style.fontWeight = "bold";
subDiv.style.border = "2px white solid";
subDiv.style.backgroundColor = "#6495ed";
subDiv.style.color = "white";
subDiv.style.width = "300px";
subDiv.style.padding = "10px";
subDiv.style.textAlign = "center";
subDiv.style.lineHeight = "20px";
subDiv.style.zIndex = 100;
subDiv.innerHTML = !!Message?Message:"正在加载数据,请稍候...";
div.appendChild( iframe );
document.body.appendChild( subDiv );
document.body.appendChild( div );
div.style.width = document.body.clientWidth;
div.style.height = document.body.clientHeight;
iframe.style.width = document.body.clientWidth;
iframe.style.height = document.body.clientHeight;
}
根据自己需要更改
<style>
.cover {
width:100%;
height:100%;
z-index:10;
position:absolute;
background:black;
filter:alpha(opacity=30);
}
</style>
<center>
<div id="div1" style="position:absolute;top:100px;background:white; z-index:11;display:none">
还原就点还原按钮<BR>
<INPUT TYPE="button" VALUE="还原" ONCLICK="fun('clear')" style="width:50px;height:50px">
</div>
</center>
<div class="cover" id="covD" style="display:none"></div>
<INPUT TYPE="button" VALUE="弹出" ONCLICK="fun('cov')">
<div style="width:50;height:50;word-wrap:no-wrap;overflow:hidden;text-overflow:ellipsis;">111111111111111111111111111111111111111111111111111111111</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fun(stat){
if (stat == "cov")
{
document.getElementById("covD").style.display = "";
document.getElementById("div1").style.display = "";
}
else {
document.getElementById("covD").style.display = "none";
document.getElementById("div1").style.display = "none";
}
}
//-->
</SCRIPT>
用一个div,left:0px,top:0px,width:屏幕宽,height:屏幕长
罩在页面上,并把背景设置成黑色。然后设置透明.
再用一个div,就是你做的消息框,盖在遮罩层上。就完成了
filter
alpha
opacity