您的位置:首页 > Web前端 > CSS

css弹出遮罩层

2015-07-29 14:51 246 查看
说明:需要jquery支持,支持IE8+,googlechrome,firefox,话不多说,上代码。

html:

[code]    <input type="button" onclick="showMaskShadow()" value="弹出遮罩层" />

    <!-- 弹出查看图片窗口 begin -->
    <div class="bgDiv"></div>
    <div class="contentDiv">
        <input type="button" onclick="hideMaskShadow()" value="点我隐藏" />
        <h2>您可以在这里自定义内容</h2>
    </div>
    <!-- 弹出查看图片窗口  end-->


css:.

[code]    /**
     * 弹出div窗口样式
     **/
    .bgDiv {
        display: none;
        position: absolute;
        top: 0%;
        left: 0%;
        width: 100%;
        height: 100%;
        background-color: black;
        z-index: 1001;
        -moz-opacity: 0.7;
        opacity: .70;
        filter: alpha(opacity = 70);
    }

    .contentDiv {
        display: none;
        position: absolute;
        top: 1%;
        left: 1%;
        width: 95%;
        height: 93%;
        padding: 8px;
        border: 8px solid #E8E9F7;
        background-color: white;
        z-index: 1002;
        overflow: auto;
        text-align: center;
    }


js:

[code]    // 弹出遮罩层
    function showMaskShadow(){
        $('.bgDiv').show();
        $('.contentDiv').show();
    }

    // 隐藏遮罩层
    function hideMaskShadow() {
        $('.bgDiv').hide();
        $('.contentDiv').hide();
    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: