实现百度登录框

今天课程要求实现百度的登录框功能,晚上花费了两个小时终于搞定,直接上代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    * {
        padding: 0;
        margin: 0;
        text-decoration: none;
        font-size: 14px/18px arial, sans-serif, "Microsoft YaHei", tahoma;
    }
    
    li {
        list-style: none;
    }
    
    input {
        outline: 0;
    }
    
    html,
    body {
        height: 1000px;
    }
    
    .ul {
        padding: 10px;
    }
    
    .mask {
        display: none;
        position: relative;
        width: 390px;
        height: 502px;
        top: 30%;
        left: 50%;
        transform: translate(-50%, -50%);
        -webkit-transform: translate(-50%, -50%);
        -moz-transform: translate(-50%, -50%);
        -ms-transform: translate(-50%, -50%);
        border: 1px solid #D9D9D9;
    }
    
    .head {
        height: 47px;
        width: 100%;
        background: #F7F7F7;
        position: relative;
    }
    
    .head_title {
        width: auto;
        height: 18px;
        font-size: 16px;
        font-family: 宋体;
        font-weight: bold;
        text-indent: 50px;
        margin-right: 29px;
        display: block;
        text-overflow: ellipsis;
        text-align: left;
        box-sizing: content-box;
        background: url("https://passport.baidu.com/passApi/img/baidu_logo_24_718a6c4.png") 18px 8px no-repeat;
        padding: 15px 0px 13px;
        overflow: hidden;
    }
    
    .close {
        width: 16px;
        height: 16px;
        position: absolute;
        right: 20px;
        top: 16px;
    }
    
    .close a {
        width: 16px;
        height: 16px;
        display: block;
        background: url('./images/icon.png') -10px -6px no-repeat;
    }
    
    .contain {
        transition: .3 ease;
    }
    
    .login {
        padding: 0 20px;
    }
    
    .phone_login {
        margin: 10px 0;
        text-align: right;
    }
    
    .color {
        font-size: 13px;
        background: url('./images/phone.png') no-repeat;
        padding-left: 15px;
    }
    
    .color:hover {
        color: #2e7fdb;
        text-decoration: underline;
    }
    
    .form .input {
        display: block;
        position: relative;
        height: 16px;
        padding: 12px 35px;
        border: 1px solid #ddd;
        font-size: 14px;
        color: #666;
    }
    
    .input {
        width: 276px;
    }
    
    .form .u {
        width: 350px;
        position: relative;
        margin-bottom: 15px;
    }
    
    .l_username,
    .l_password {
        display: block;
        position: absolute;
        top: 8px;
        left: 6px;
        width: 0;
        height: 24px;
        overflow: hidden;
        padding: 0 0 0 24px;
        background: url('./images/login.png') 0 -69px no-repeat;
        z-index: 11;
    }
    
    .l_password {
        background-position: 0 -147px;
    }
    
    .verify {
        display: flex;
    }
    
    .verifyImg {
        border: 1px solid #ddd;
        margin-right: auto;
        margin-left: auto;
        width: 100px;
        height: 42px;
    }
    
    .verifyCode {
        width: 160px;
        padding: 0 0 0 15px;
        margin-right: 10px;
        border: 1px solid #ddd;
    }
    
    .change {
        display: flex;
        align-items: center;
        cursor: pointer;
    }
    
    .check {
        display: flex;
        font-size: 14px;
    }
    
    .auto_log {
        margin-right: auto;
    }
    
    .checkbox {
        vertical-align: middle;
    }
    
    .button_submit {
        width: 350px;
        background-color: #4490f7;
        display: block;
        height: 48px;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
        color: #fff;
        border-radius: 5px;
        margin-bottom: 15px;
    }
    
    .reg {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 55px;
    }
    
    .auth {
        border-top: 1px solid #eee;
        padding: 8px 0 5px 15px;
    }
    
    .qq,
    .wb {
        display: block;
        background: url('./images/icon.png') -73px -127px no-repeat;
        height: 32px;
        width: 38px;
        overflow: hidden;
    }
    
    .auth_ul {
        padding: 8px 0 0;
        display: flex;
    }
    
    .wb {
        background-position: 0px -127px;
        margin-left: 15px;
    }
    
    .qc {
        width: 44px;
        height: 44px;
        position: absolute;
        right: 0;
        bottom: 0;
        cursor: pointer;
        background: url('./images/icon.png') no-repeat -129px -47px;
        z-index: 21;
        overflow: hidden;
    }
    
    .code {
        z-index: 11;
        position: absolute;
        left: 0;
        top: 47px;
        width: 390px;
        height: 450px;
        background: #fff;
        transition: .3 ease;
        display: none;
    }
    
    .code_con {
        width: 160px;
        margin: 50px auto;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .code_title {
        margin-bottom: 25px;
        font-size: 16px;
    }
    
    .code_img {
        width: 160px;
        height: 160px;
        text-align: center;
        line-height: 160px;
    }
    
    .code_img img {
        width: 135px;
        height: 135px;
    }
    </style>
</head>

<body>
    <nav>
        <ul class="ul">
            <li><a href="#" id="login">登录</a></li>
        </ul>
    </nav>
    <div class="mask" id="mask">
        <div class="head">
            <div class="head_title">
                登录百度账号
            </div>
            <div class="close">
                <a href="#" id="close"></a>
            </div>
        </div>
        <!--con sta-->
        <div class="contain" id="contain">
            <div class="login">
                <div class="phone_login">
                    <a class="color" href="#">短信快捷登录</a>
                </div>
                <form action="#" method="post" class="form">
                    <div class="div_username u">
                        <label for="username" class="l_username"></label>
                        <input type="text" name="username" class="username input" placeholder="手机/邮箱/用户名">
                    </div>
                    <div class="div_password u">
                        <label for="password" class="l_password"></label>
                        <input type="text" name="password" class="password input" placeholder="密码">
                    </div>
                    <div class="verify u">
                        <input type="text" name="verifyCode" class="verifyCode" maxlength="6" placeholder="验证码">
                        <div class="verifyImg">![](./images/genimage.png)</div>
                        <div class="color change" style="background: none;">换一张</div>
                    </div>
                    <div class="u check">
                        <div class="auto_log">
                            <input type="checkbox" class="checkbox" checked="checked">
                            <label class="">下次自动登录</label>
                        </div>
                        <div><a href="#" target="_blank">登录遇到问题</a></div>
                    </div>
                    <input type="submit" value="登录" class="button_submit">
                </form>
                <div class="reg">
                    <a class="color change" style="background: none;" href="#" target="_blank">立即注册</a>
                </div>
            </div>
            <div class="auth">
                <div class="" style="font-size: 14px;">可以使用以下方式登录</div>
                <div class="auth_logo">
                    <ul class="auth_ul">
                        <li>
                            <a href="#" class="qq"></a>
                        </li>
                        <li>
                            <a href="#" class="wb"></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <!--con end-->
        <!--code sta-->
        <div class="code" id="code">
            <div class="code_con">
                <h2 class="code_title">手机扫描,安全登陆</h2>
                <div class="code_img">
                    ![](./images/qrcode.png)
                </div>
                <p style="font-size:12px;">请使用手机百度app扫描登录</p>
            </div>
        </div>
        <!--code sta-->
        <div class="qc" id="qc"></div>
    </div>
    <script>
    var mask = document.getElementById("mask");
    var login = document.getElementById("login");
    var close = document.getElementById("close");
    var qc = document.getElementById("qc");
    var contains = document.getElementById("contain");
    var code = document.getElementById("code");
    var log = true;
    close.onclick = function() {
        mask.style.display = "none";
    };
    login.onclick = function() {
        mask.style.display = "block";
    };
    qc.onclick = function() {
        if (log) {
            contains.style.display = "none";
            code.style.display ="block";
            log = false;
        }else{
            contains.style.display = "block";
            code.style.display ="none";
            log = true;
        }
        
    };

   
    </script>
</body>

</html>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,233评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,013评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,030评论 0 241
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,827评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,221评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,542评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,814评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,513评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,225评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,497评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,998评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,342评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,986评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,055评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,812评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,560评论 2 271
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,461评论 2 266

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 170,563评论 25 707
  • 2017.02.22 可以练习,每当这个时候,脑袋就犯困,我这脑袋真是神奇呀,一说让你做事情,你就犯困,你可不要太...
    Carden阅读 1,248评论 0 1
  • TraitsUI介绍 Group对象组织界面 使用多个视图对象 配置视图 truitsUI控件
    不做大哥好多年阅读 2,236评论 0 1
  • 家事 诗/陈木述春 炉火边, 你唇像火焰, 木柴化尽灰,成烟, 一点星火, 可为你, ...
    诗人陈述阅读 176评论 0 3
  • ​今天看了一条新闻,大概是这样写的:一对夫妻,丈夫多次对妻子信息“已读不回”,妻子请求离婚,并将未回信息的聊天记录...
    暮光fillette阅读 2,273评论 0 1