setTimeOut定时弹出居中窗口

来源:互联网 发布:ubuntu虚拟机安装教程 编辑:程序博客网 时间:2024/06/06 00:20
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        #contant{
            width:200px;
            height:200px;
            border:1px solid darkslategray;
            background:yellowgreen;
            top:50%;
            left:50%;
            position:fixed;
            margin-left:-100px;
            margin-top:-100px;
            line-height: 200px;
            font-size: 50px;
            text-align: center;
        }
        #close{
            font-size: 16px;
            line-height: 20px;
            color:#fff;
            width:20px;
            height:20px;


            position: absolute;
            top:0;
            right:0;
            background:red;
        }
    </style>
    <script type="text/javascript">
        window.onload=function(){
         var cle=document.getElementById("close");
         var box=document.getElementById("contant");
            function ds(){
                box.style.display="block";
            }


            cle.onclick=function(){
                box.style.display="none";


                setTimeout(ds,2000);
                console.log(box.style.display);


            }
        }
    </script>
</head>
<body>
<div id="contant">
   <div id="close">x</div>
    联系我
</div>
</body>
</html>
0 0
原创粉丝点击