zoukankan      html  css  js  c++  java
  • 2017 年9月29日 弹出层特效

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

    <html>

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

  • 相关阅读:
    css选择器学习(二)属性选择器
    css选择器学习(一)
    css引用优先级
    canvas制图学习
    cookie,localStorage,sessionStorage
    HTTP协议中get和post的区别
    台灯发展史
    Object类实现的方法
    react学习网站
    什么是接口测试,接口测试的目的,如何进行接口测试
  • 原文地址:https://www.cnblogs.com/zJuevers/p/7612894.html
Copyright © 2011-2022 走看看