web前端遮罩

在这里插入图片描述

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .box{
            width: 400px;
            height: 400px;
            position: relative;
            text-align: center;
            background-color:rgba(200,152,241,0.3);
            margin: 0 auto;
        }
        .win{
            width: 160px;
            height: 120px;
            background-color:#fff;
            border: 1px solid #ccc;
            position: absolute;
            left: 50%;
            top: 50%;
            margin-left: -80px;
            margin-top: -60px;
            z-index: 999;
            display: none;
        }
        .lightbox{
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,.6);
            position: fixed;
            z-index: 99;
            display: none;
        }
        .touch_me{
            cursor: pointer;
        }
    </style>
    <script>
        window.onload=function(){

            function $(id){
               return document.getElementById(id);
            }
            $("touch_me").onclick=function(){
                $("light_box").style.display="block";
                $("win").style.display="block";
            }
            $("winner").onclick=function(){
                $("light_box").style.display="none";
                $("win").style.display="none";
            }
        }
    </script>
</head>
<body>
    <div class="lightbox" id="light_box"></div>
    <div class="box" >
        <div class="good-boy" id="good_boy">

            <div class="win" id="win">
                <p><span  id="winner">关闭</span></p>
                这里是弹窗内容
            </div>
        </div>
        <span id="touch_me" class="touch_me">点击我</span>
    </div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值