jquery控制div层首次加载3秒关闭,内容居中显示

 

样式:
<style>
        .cover{
            position: fixed;
            top:0;
            right:0;
            bottom:0;
            left:0;
            background-color: rgba(0,0,0,0.2);
            z-index:9998;
        }
        .modal {
           left:50%;
            width:100%;
            height:1080px;
            margin-left:-50%;
            position: fixed;
			margin-top:0px;
            background-size: cover;
            /*padding-bottom: 145%;*/
            z-index: 9999;
			text-align:center
        }
        .close {
            float: right;
            /*在这里将x移动到右上角*/
            margin-right: 15px;
            margin-top: 10px;
            font-size: 16px;
            cursor:pointer;
        }
        .hide {
            display: none;
            /*表示不显示*/
        }
    </style>
<body>

    <div class="cover hide" ></div>
    <div class="modal hide">
        <%--<span class="close" id="close">×</span>--%>
        <img ID="img" src="" style="margin:auto;margin-top:0px;"/>
    </div>
</body>
      $(".modal").css({ height:$(window).height()+'px', width: $(window).width() + 'px'});
        $("#img").css({height:$(window).height()+'px', width: $(window).width() + 'px'})

        $(function () {
            
            var first = sessionStorage.getItem("first");  //首次加载

            //首次加载
            if (!first) {
                sessionStorage.setItem("first", "1");
                $(".modal").removeClass("hide")
                $(".cover").removeClass("hide")
                $("#close").click(function () {
                    $(".modal").addClass("hide")
                    $(".cover").addClass("hide")
                })
                //展示3秒
                setTimeout(function () {
                    $(".modal").addClass("hide")
                    $(".cover").addClass("hide")
                },3000)
           }
        })

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值