关于#html#的问题,如何解决?

img

向b站这种弹框出现了后,点其他位置没有效果。只有把登录弹框关闭才能点击其他位置

这种效果怎么做啊

用一个遮罩层,只有点了登录框的关闭按钮才能触发取消遮罩层

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试</title>
    <style type="text/css">
        .main{
            height: 1200px;
            background-color: orange;
        }
        .box-1{
            background-color: black;
            opacity: 0.6;
            position: fixed;
            z-index: 100000;
            display: none;
            top: 0;
            left: 0;
        }
        #login{
            cursor: pointer;
        }
        .box-1 >div{
            float: left;
        }
        .box-main{
            width: 95%;
            height: 100%;
        }
        .tuichu{
            width: 5%;
        }
        .tuichu p{
            background-color: black;
            color: white;
            font-weight: bold;
            font-size: 20px;
            width: 100%;
            text-align: center;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="main">
        <div id="login">登录</div>
        <a href="https://wwww.baidu.com">baidu</a>
    </div>
    <div class="box-1">
        <div class="box-main"></div>
        <div class="tuichu">
            <p>X</p>
        </div>
    </div>
    <script type="text/javascript">
        var login = document.querySelector('#login');
        var box_1 = document.querySelector('.box-1');
        var tuichu = document.querySelector('.tuichu');
        login.onclick = function(){
            let w = window.innerWidth;
            let h = window.innerHeight;
            console.log(w,h);
            box_1.style.width = w +'px';
            box_1.style.height = h + 'px';
            box_1.style.display = 'block';
        }

        tuichu.onclick = function(){
            box_1.style.display = 'none';
        }
    </script>
</body>
</html>

虽然我不知道B站是怎样实现的,但是我觉得我这样可以实现,主要修改z-index这个属性值。

img