zoukankan      html  css  js  c++  java
  • 弹出层

    <!DOCTYPE html>
    <html>
    
        <head>
            <meta charset="UTF-8">
            <title></title>
            <style>
                * {
                    margin: 0px;
                    padding: 0px;
                }
                
                .mask {
                     100%;
                    height: 500px;
                    background-color: black;
                    opacity: 0.5;
                    position: fixed;
                    top: 0px;
                    left: 0px;
                    z-index: 400;
                }
                
                .out {
                     300px;
                    height: 200px;
                    background-color: green;
                    position: fixed;
                    /*top: 100px;
                    left: 100px;*/
                    z-index: 998;
                }
            </style>
            <script src="js/sweetalert2.min.js"></script>
            <link rel="stylesheet" href="css/sweetalert2.min.css" />
        </head>
    
        <body>
            <input type="button" value="弹出" id="btn1" />
            <div class="mask" hidden="hidden"></div>
            <div class="out" hidden="hidden"></div>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
            <p>123</p>
        </body>
    
    </html>
    <script>
        var mask = document.getElementsByClassName("mask")[0];
        var out = document.getElementsByClassName("out")[0];
        var btn1 = document.getElementById("btn1");
        var c_height = document.documentElement.clientHeight;
        var c_width = document.documentElement.clientWidth;
        var top_ = c_height / 2 - 100;
        var left = c_width / 2 - 150;
    
        mask.style.height = c_height + "px";
        out.style.top = top_ + "px";
        out.style.left = left + "px";
    
        btn1.onclick = function() {
            mask.removeAttribute("hidden");
            out.removeAttribute("hidden");
        }
        mask.onclick = function() {
            mask.setAttribute("hidden", "hidden");
            out.setAttribute("hidden", "hidden");
        }
    
        window.onresize = function() {
            var c_height = document.documentElement.clientHeight;
            var c_width = document.documentElement.clientWidth;
            var top_ = c_height / 2 - 100;
            var left = c_width / 2 - 150;
    
            mask.style.height = c_height + "px";
            out.style.top = top_ + "px";
            out.style.left = left + "px";
        }
    
        swal(
            '1',
            '2',
            'success'
        )
    </script>
  • 相关阅读:
    对于对象的要求:高内聚、低耦合,这样容易拼装成为一个系统
    为什么要使用面向对象
    什么是对象:EVERYTHING IS OBJECT(万物皆对象)
    文件 I/O 问题
    如果可能的话,使用 PC-Lint、LogiScope 等工具进行代码审查
    把编译器的选择项设置为最严格状态
    尽量不要使用与具体硬件或软件环境关系密切的变量
    尽量使用标准库函数
    如果原有的代码质量比较好,尽量复用它
    不要设计面面俱到、非常灵活的数据结构
  • 原文地址:https://www.cnblogs.com/yangchuanqi/p/7613252.html
Copyright © 2011-2022 走看看