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: ghostwhite;
                    opacity: 0.5;
                    z-index: 998;
                    position: absolute;
                    top: 0px;
                    left: 0px;
                }
                .login{
                     400px;
                    height: 300px;
                    background-color: gainsboro;
                    position: fixed;
                    /*left: 200px;             通过js读取,不需要定义   
                    top: 300px;*/
                    z-index:999;
                }
                .close-btn{
                    30px;
                    height:30px;
                    position:absolute;
                    top:10px;
                    right:10px;
                    background-color: gray;
                    text-align: center;
                    line-height: 30px;
                }
                .close-btn:hover{
                    cursor: pointer;}
                    #a1{
                         300px;
                        height: 450px;
                        position: absolute;
                    }
                #inner{
                     250px;
                    height: 40px;
                    position: relative;
                    
                    left: 60px;
                    text-align: center;
                    vertical-align: middle;
                    line-height: 40px;
                    
                    
                }
                .yonghuming{
                    position: relative;
                    margin-top: 50px;
                    
                }
            </style>
        </head>
        <body>
            <!--<input type="button" value="登录" onclick="showLogIn()" />-->  
            <!--目的是换用文字,不使用input作为按钮-->
            <p onclick="showLogIn()" >登录</p>          <!--给文字添加onclick事件-->
            
            <!--以下div为弹出框中的内容,要设置其display属性为none,因为只要它们在遮罩层中显示-->
            <div id="a1" style="display: none;">
                <div id='inner' class='yonghuming'> 
                用户名:<input type="text" placeholder="用户名/手机号">
                </div>
                <div id='inner'class='password'>
                    密码:&nbsp;&nbsp;<input type="password" placeholder="请输入密码">
                </div>
                <div id='inner'class='denglu' style="background-color:gray;margin-top: 10px;
                    220px ;margin-left: 18px;">登录</div>
                <div id='inner'class='weizhuce'><br />没有账号?-点击注册</div>
            </div>    
            
            
        </body>
    </html>
    <script>
        function showLogIn(){
            var bodyHeight=document.body.clientHeight;       // 获取内容高度
            var clientHeight=document.documentElement.clientHeight;
            var clientWidth=document.documentElement.clientWidth;
     //创建div,即最大的遮罩层    
            var mask=document.createElement("div");     
            mask.className="mask";
            mask.style.height=bodyHeight+"px";
                document.body.appendChild(mask);
    //点击遮罩层任意一处,退出遮罩层
            mask.onclick=function(){
                mask.remove();
                login.remove();
            }
    //    创建新div
            var login=document.createElement("div");
            login.className="login";
              //使登陆框位于中间位置
            login.style.left=clientWidth/2-200+"px";      
            login.style.top=clientHeight/2-150+"px";  
    //去掉display属性,使div能够显示
            var d=document.getElementById("a1").removeAttribute("display");  
    //        将关闭按钮和id为a1的div写进classname为login的div中
            login.innerHTML="<div class='close-btn'>X</div>"+ document.getElementById("a1").innerHTML;
            document.body.appendChild(login);
    //点击关闭按钮,退出遮罩层
            document.getElementsByClassName("close-btn")[0].onclick=function(){
                mask.remove();
                login.remove();
            }
        }
        
    //当窗体大小发生变化时,让登陆框随窗体大小而改变
        document.body.onresize = function(){
            var clientHeight = document.documentElement.clientHeight;
            var clientWidth = document.documentElement.clientWidth;
            var login = document.getElementsByClassName("login")[0];
            login.style.left = clientWidth/2 - 200 + "px";
            login.style.top = clientHeight/2 - 150 + "px";
        }
    </script>

    登录页面(带遮罩层的)

  • 相关阅读:
    很简单的企业管理器我写程序的方式,几个自定义控件。
    当OO遇到了持久化?!
    [自定义服务器控件] 第一步:文本框。
    [面向过程——老酒换新瓶] (一)开篇:是面向过程还是面向对象?
    个人理财小助手 —— 设计思路、功能说明
    《Head First 设计模式》 终于出中文版了。
    其实添加数据也可以这样简单——表单的第一步抽象(针对数据访问层)《怪怪设计论: 抽象无处不在 》有感
    基类、接口的应用——表单控件:一次添加、修改一条记录,一次修改多条记录。(上)
    其实添加数据也可以这样简单——表单的第三步抽象(针对UI及后置代码)
    转帖:客户端表单通用验证checkForm(oForm) js版
  • 原文地址:https://www.cnblogs.com/douchenchen/p/6672925.html
Copyright © 2011-2022 走看看