• 利用遮罩层做登录页面


    <head>

    <style>
       * {
        margin: 0px;
        padding: 0px;
       }
       
       #mask {
         100%;
        background-color: black;
        opacity: 0.3;
        position: fixed;
        left: 0px;
        top: 0px;
       }
       
       #pop-login {
         300px;
        height: 100px;
        position: fixed;
        background-color: white;
       }

       #close-pop {
        position: absolute;
        top: 3px;
        right: 3px;
       }
      </style>
     </head>

    <body>
      <input type="button" value="登录" id="login-btn" />      //添加登录按钮

    <body>

    <script>

        document.getElementById('login-btn').onclick = function() {
        var b_width = document.body.clientWidth;            //获取整个页面的宽度
        var b_height = document.documentElement.clientHeight;     //获取整个页面的高度
        var left = b_width / 2 - 150 + 'px';
        var top = b_height / 2 - 50+ 'px';                    //使登录框居中

        var mask = document.createElement('div');

        mask.style.height = b_height + 'px';              //使遮罩层高度能够覆盖整个页面

        mask.id = 'mask';

        document.body.appendChild(mask);

        var pop_login = document.createElement('div');
        pop_login.style.left = left;
        pop_login.style.top = top;
        pop_login.id = 'pop-login';                           //使登录框能够居中显示
        pop_login.innerHTML =
                                      '<form action="#" method="post">' +
                                      '<input type="text" name="uid" placeholder="请输入用户名" />' +
                                      '<input type="password" name="pwd" />' +
                                      '<input type="submit" value="提交" />' +
                                      '</form>' +
                                      '<div id="close-pop">X</div>';                   //添加登录框
        document.body.appendChild(pop_login);
        document.getElementById('close-pop').onclick = function(){
                      document.body.removeChild(mask);
                      document.body.removeChild(pop_login);                         //给x添加点击事件,移除登录框和遮罩层
        }

        mask.onclick = function() {
        document.body.removeChild(mask);
        document.body.removeChild(pop_login);                                //给遮罩层添加点击事件,移除登录框和遮罩层
         }
     }

  • 相关阅读:
    method-r
    dtrace
    轻用其芒,动即有伤,是为凶器;深藏若拙,临机取决,是为利器!
    Git---报错:git Please move or remove them before you can merge 解决方案
    Git----拉取远程分支,git pull,git rebase,git pull --rebase的区别
    Git----查看提交日志
    Git---tag
    Git----常见工作管理总结
    【线上监控】日志上报bug处理方式总结
    接口文档所需内容
  • 原文地址:https://www.cnblogs.com/gonghuixin/p/6766844.html
Copyright © 2020-2023  润新知