弹出信息窗我会,但是不知道怎么让后边的主内容变暗

解决方案 »

  1.   

    变暗也是一个黑色的div,在这个div上设置透明度就可以了
    设置透明度的css代码如下:
    filter:alpha(opacity=70);
    -moz-opacity:0.70;
    -khtml-opacity: 0.7;
    opacity:0.7;
      

  2.   


    $("#id").animate({"opacity":"0.5"},3000);
      

  3.   

    搞个稍微全的demo,我也想学习一下
      

  4.   


    /***************************************************************** 弹出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;
    }
    根据自己需要更改
      

  5.   


      <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>
      

  6.   

    总体思路
    用一个div,left:0px,top:0px,width:屏幕宽,height:屏幕长
    罩在页面上,并把背景设置成黑色。然后设置透明.
    再用一个div,就是你做的消息框,盖在遮罩层上。就完成了
      

  7.   

    这个主要还是要设置背景或滤镜效果
    filter
    alpha
    opacity