码迷,mamicode.com
首页 > 其他好文 > 详细

2017 年9月29日 弹出层特效

时间:2017-09-30 00:40:09      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:弹出层   弹出框   var   padding   cti   idt   htm   function   put   

点击登录会出现弹出框,有点错误.没搞明白,  为什么会不居中

<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            * {
                margin: 0px;
                padding: 0px;
            }
            
            .div1 {
                width: 100%;
                height: 500px;
                background-color: black;
                opacity: 0.5;
                position: fixed;
                top: 0px;
                left: 0px;
                z-index: 40;
            }
            
            .div {
                width: 300px;
                height: 200px;
                background-color: red;
                position: fixed;
                top: 100px;
                left: 100px;
                z-index: 80;
            }
        </style>
    </head>

    <body>
        <input type="button" value="登陆" id="b1" />
        <div class="div1" hidden="hidden"></div>
        <div class="div" hidden="hidden"></div>
    </body>

</html>
<script>
    var div1 = document.getElementsByClassName("div1")[0];
    var div = document.getElementsByClassName("div")[0];
    var b1 = document.getElementById("b1");
    var c1 = document.documentElement.clientHeight;
    var c2 = document.documentElement.clientWidth;
    var a1 = c1 / 2 - 100;
    var a2 = c2 / 2 - 150;

    div1.style.height = c1 + "px";
    div.style.top = a1 + "px";
    div.style.a2 = a2 + "px";

    b1.onclick = function() {
        div1.removeAttribute("hidden");
        div.removeAttribute("hidden");
    }
    div1.onclick = function() {
        div1.setAttribute("hidden", "hidden");
        div.setAttribute("hidden", "hidden");
    }

    window.onresize = function() {
        var c1 = document.documentElement.clientHeight;
        var c2 = document.documentElement.clientWidth;
        var a1 = c1 / 2 - 100;
        var a2 = c2 / 2 - 150;

        div1.style.height = c1 + "px";
        div.style.top = a1 + "px";
        div.style.a2 = a2 + "px";
    }
</script>

2017 年9月29日 弹出层特效

标签:弹出层   弹出框   var   padding   cti   idt   htm   function   put   

原文地址:http://www.cnblogs.com/zJuevers/p/7612894.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!