遮罩层

来源:互联网 发布:工业企业如何审计 知乎 编辑:程序博客网 时间:2024/05/22 05:05

页面内放俩div,一个用来全屏变灰,一个用来显示弹出的框

<div id="myDiv"style="left: 0px; top: 0px; width: 3000px; height: 1000px; display: none; position: absolute; z-index: 60;background-color: gray;opacity:0.5;        filter:Alpha(opacity=50);"></div>        <div id="alert" style="position:fixed; top: 0; left: 0; right: 0; bottom: 0; opacity: 1; z-index: 10000; top: 150px; display: none;">            <div style="z-index:10001; background: #fff; width:300px;margin-right:auto;margin-left:auto;padding:10px;text-align:center;margin:0 auto;border-radius:5px;">            </div>        </div>

js控制方法

        var imgDiv = document.getElementById("alert");        var oDiv2 = document.getElementById("myDiv");        // 打开        function Open() {            oDiv2.style.display = "inline";            imgDiv.style.display = "inline";        }        // 关闭        function Close() {            oDiv2.style.display = "none";            imgDiv.style.display = "none";            return false;        }
原创粉丝点击