遮挡层 滚动条 上下固定

在这里插入图片描述
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .dj{
           
            width: 500px;
            height: 800px;
           position: relative;
    background:url(./1.jpg),url(./2.jpg);
    background-repeat: no-repeat, no-repeat;
    background-position-y:top,bottom;
    /* background-attachment:fixed; */
    background-size:100% 200px,100% 200px;
    overflow: hidden;
        }
        .zzc{
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 600px;
            background-color:rgba(0,0,0,.3);
            width: 500px;
            display: none;
            font-size: 30px;
        }
        .xs{
            width:300px ;
            position: absolute;
            top: 0;
            left: -100px;
            right: 0;
            bottom: 0;
            background-color: #fff;
            transition: all 0.3s;
        }
    </style>
</head>
<body>
    <div class="dj">点击
        <div style="position: absolute;top:200px;bottom: 200px;overflow: auto; background-color: pink;   font-size: 30px;" > 
        111111111111111111111111
      优雅的大白鹅啊
        555555555555555
        优雅的大白鹅啊
        777777777777777
       喝奶茶不要珍珠
        333333333333333
        44444444444444444
        555555555555555
        66666666666666
        777777777777777  111111111111111111111111
        333333333333333
        44444444444444444
        555555555555555
        666666666666
        111111111111111111111111
        333333333333333
        </div>
    </div>
    <div class="zzc">
        <div class="xs">
            66是个爱睡在床垫下面的假猫咪
        </div>
    </div>
    <script>
        var dj=document.querySelectorAll('.dj')
        var zzc=document.querySelectorAll('.zzc')
        var body =document.body
        var xs=document.querySelectorAll('.xs')
        console.log(dj)
        dj[0].onclick=function () {
            zzc[0].style = "display:block";
            body.style='overflow: hidden;'
                setTimeout(res=>{
                xs[0].style = "left:0px"
            })
        }
        zzc[0].onclick=function(){
            xs[0].style = "left:-100px"
            setTimeout(res=>{
            zzc[0].style = "display:none"
            },300)
        }
        xs[0].onclick=function(event){
        event.stopPropagation(); 
    }

    </script>
</body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值