美文网首页
2018-11-01day4-京东登录静态页面

2018-11-01day4-京东登录静态页面

作者: MW演员 | 来源:发表于2018-11-02 09:18 被阅读0次

    一、HTML代码

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <!-- 设置网页标题 -->
            <title>京东-欢迎登录</title>
            
            <!-- 设置网页图标 -->
            <link rel="icon" type="img/ico" href="img/jd_logo.ico"/>
            <link rel="stylesheet" type="text/css" href="css/loginstyle.css"/>
        </head>
        <body>
            <!-- ========================头部========================= -->
            <div id="header">
                <!-- =======顶部的顶部========= -->
                <div id="top">
                    <div>
                        <a href="https://www.jd.com/"><img src="img/logo.png" ></a>
                        <a href=""><img src="img/l-icon.png" ></a>
                    </div>
                    <a id="survey" href="https://surveys.jd.com/index.php?r=survey/index/sid/568245/lang/zh-Hans" target="_blank">登录页面,调查问卷</a>
    
                </div>
                
                <!-- =======顶部的底部========= -->
                <div id="bottom">
                    <p><img src="img/warning.png" >&emsp;&emsp;&nbsp;依据《网络安全法》,为保障您的账户安全和正常使用,请尽快完成手机号验证! 新版<a href="https://about.jd.com/privacy/" target="_blank">《京东隐私政策》</a>上线,将更有利于保护您的个人隐私。</p>
                </div>
                
            </div>
            
            <!-- =======================中间内容部分============================== -->
            <div id="content">
                <!-- 登录框 -->
                <div id="login_page">
                    <!-- 提示块 -->
                    <div id="div1">
                        <p><img src="img/xx.png">&emsp;&emsp;京东不会以任何理由要求您转账汇款,谨防诈骗。</p>
                    </div>
                    
                    <!-- 按钮块 -->
                    <div id="div2">
                        <button type="button" id="btn1">扫码登录</button>|
                        <button type="button" id="btn2">账号登录</button>
                    </div>
                    <!-- 信息块 -->
                    <div id="div3">
                        <!-- 用户名 -->
                        <div id="username">
                            <img src="img/pygame.png" >
                            <input type="text" name="username" id="user" value="" placeholder="邮箱/用户名/已验证手机"/>
                        </div>
                        <!-- 密码 -->
                        <div id="password">
                            <img src="img/password_icon.png" >
                            <input type="password" name="password" id="pwd" value="" placeholder="密码"/>
                        </div>
                        <a href="">忘记密码</a>
                        <button type="button">登&emsp;录</button>
                        
                    </div>
                    <!-- 注册和第三方登录 -->
                    <div id="div4">
                        <!-- 第三方登录 -->
                        <a id="a1" class="a1" href="https://graph.qq.com/oauth2.0/show">QQ</a>|
                        <a id="a2" class="a1" href="https://open.weixin.qq.com/connect/qrconnect?appid=wx827225356b689e24&state=64A4BFA038D0868125BD4927EA06CDCA658549F46D8C10F7D196052C36975B334C1A394F83F31B5ECD31B28A4CDA081A&redirect_uri=https%3A%2F%2Fqq.jd.com%2Fnew%2Fwx%2Fcallback.action%3Fview%3Dnull%26uuid%3D95bfea9c751c4ebe8566e8be60e6f3ad&response_type=code&scope=snsapi_login#wechat_redirect">微信</a>
                        
                        <!-- 立即注册 -->
                        <a id="a3" href="https://reg.jd.com/reg/person?ReturnUrl=http%3A%2F%2Fwww.jd.com">立即注册</a>
                    </div>
                </div>
            </div>
            
            <!-- ========================底部===================== -->
            <div id="footer">
                <div>
                    <a href="https://www.jd.com/">关于我们</a>|
                    <a href="http://about.jd.com/contact">联系我们</a>|
                    <a href="https://zhaopin.jd.com/">人才招聘</a>|
                    <a href="https://www.jd.com/">商家入驻</a>|
                    <a href="https://www.jd.com/">广告服务</a>|
                    <a href="https://app.jd.com/">手机京东</a>|
                    <a href="https://club.jd.com/links.aspx">友情链接</a>|
                    <a href="https://media.jd.com/">销售联盟</a>|
                    <a href="https://sale.jd.com/act/n0hAvqy5CW8.html">京东社区</a>|
                    <a href="https://gongyi.jd.com/">京东公益</a>
                    <a href="https://www.jd.com/">English Site</a>
                </div>
                
                <p>Copyright © 2004-2018  京东JD.com 版权所有</p>
            </div>
        </body>
    </html>
    

    二、css样式

    /* =========================通用============================ */
    *{
        /* 消除默认的margin值 */
        margin: 0;
        /* 消除默认的padding值 */
        padding: 0;
        /* 让所有的标签的字标签都相对自己定位 */
        position: relative;
    }
    
    /* =========================顶部布局============================= */
    #header{
        /* background-color: seagreen; */
        height: 130px;
    }
    
    /* <!-- =======顶部的顶部========= --> */
    #header #top{
        height: 80px;
        background-color: white;
    }
    
    #header #top div{
        width: 292px;
        height: 60px;
        /* background-color: green; */
        /* 相对定位会让标签脱流 */
        position: absolute;
        left: 188px;
        
        /* 垂直居中 */
        top: 50%;
        margin-top: -30px;
        /* 标签高度 */
        line-height: 60px;
    }
    #header #top #survey{
        /* 布局 */
        position: absolute;
        right: 187px;
        bottom: 10px;
        color: rgb(180, 180, 180);
        font-size: 12px;
        text-decoration: none;
        
        /* 添加背景图 
        background:url(图片地址) repeat/no-repeat(是否平铺) x坐标 y坐标 背景颜色;
        x,y:两个坐标对应的值,除了可以设置数字以外,还可以设置center,让背景图在x或y坐标方向上居中
        */
       padding-left: 22px;
       background: url(../img/q-icon.png) no-repeat 0 center white;
      
    }
    #header #top #survey:hover{
        color: red;
        text-decoration: underline;
    }
    
    
    /* <!-- =======顶部的底部========= --> */
    #header #bottom{
        height: 50px;
        background-color: #FFF8F0;
    }
    
    #header #bottom{
        /* 文字垂直方向居中 */
        height: 100%;
        line-height: 50px;
        /* 水方向居中 */
        text-align: center;
        /* 设置字体大小 */
        font-size: 10px;
        color: rgb(180, 180, 180);
    }
    
    #header #bottom p img{
        /* 标签垂直居中 */
        height: 25px;
        position: absolute;
        top: 50%;
        margin-top: -12px;
        line-height: 25px;
    }
    
    #header #bottom a{
        /* 去掉下划线 */
        text-decoration: none;
        /* 改变字体颜色 */
        color: rgb(70,70,70);
    }
    
    #header #bottom a:hover{
        /* 鼠标悬停加上下划线 */
        text-decoration: underline;
    }
    
    
    /* ========================中间部分布局============================= */
    #content{
        height: 470px;
        background: url(../img/bg.png) no-repeat 15% center rgb(233,56,84);
    
    }
    /* =====================登录界面=========== */
    #content #login_page{
        width: 350px;
        height: 400px;
        background-color: white;
        /* 定位 */
        position: absolute;
        top: 2%;
        right: 10%;
    }
    /* =====提示块====== */
    #content #login_page #div1{
        height: 40px;
        background-color: rgb(255, 246, 236);
    
    }
    #content #login_page #div1 img{
        height: 16px;
        position: absolute;
        top: 50%;
        margin-top: -8px;
        line-height: 16px;
    }
    
    #content #login_page #div1 p{
        height: 40px;
        line-height: 40px;
        font-size: 12px;
        
        /* 水平方向居中 */
        text-align: center;
        color: rgb(180, 180, 180);
    }
    
    /* =================选择登录方式块============ */
    #content #login_page #div2{
        height: 60px;
        /* background-color: white; */
        color: rgba(220, 220,220, 0.6);
        /* 设置字体粗细,取值范围在100到900依次增大 */
        font-weight: 100;
    }
    
    #content #login_page #div2 button{
        width: 48%;
        height: 100%;
        background-color: white;
        
        /* 去掉边框 */
        border: 0;
        
        font-size: 18px;
        color: rgb(60, 60, 60);
    }
    
    /* 设置按钮成为焦点的状态 */
    #content #login_page #div2 button:focus{
        color: #FF0000;
        /* 按钮成为焦点时的默认效果outline */
        outline: none;
    }
    
    
    
    /* ===================信息收集块============== */
    #content #login_page #div3{
        height: 250px;
        /* background-color: rgb(255, 0, 236); */
        /* 设置边框 */
        border-top: solid rgba(230, 230, 230, 0.4) 1px;
        border-bottom: solid rgba(230, 230, 230, 0.4) 1px;
    }
    /* 选中3里面的全部div */
    #content #login_page #div3 div{
        width: 300px;
        height: 40px;
        /* background-color: #DEB887; */
        
        /* 设置输入框的的位置 */
        margin-left: 8%;
        margin-top: 23px;
        /* 设置输入框的边框 */
        border: solid rgb(200, 200, 200) 1px;
    }
    /* 设置username的上边距 */
    #content #login_page #div3 #username{
        margin-top: 35px;
    }
    /* 设置图片大小 */
    #content #login_page #div3 div img{
        width: 40px;
        height: 40px;
        float: left;
        border-right: solid rgb(200, 200, 200) 1px;
    }
    
    /* 设置输入框大小大小 */
    #content #login_page #div3 div input{
        width: 245px;
        height: 40px;
        /* 设置输入框的位置 */
        border: 0;
        float: left;
        
        /* 设置输入框中的光标位置 */
        padding-left: 10px;
        
        /* 设置字体大小 */
        font-size: 14px;
    }
    
    /* 设置输入框成为焦点时的状态 */
    #content #login_page #div3 div input:focus{
        /* color: #FF0000; */
        /* 按钮成为焦点时的默认效果outline */
        outline: none;
    }
    /* 设置忘记密码的位置 */
    #content #login_page #div3 a{
        position: absolute;
        right: 25px;
        margin-top: 20px;
        font-size: 12px;
        color: rgb(80, 80, 80);
        text-decoration: none;
    }
    /* 设置a标签的焦点状态 */
    #content #login_page #div3 a:hover{
        color: red;
        text-decoration: underline;
    }
    
    /* 设置登录按钮位置和布局 */
    #content #login_page #div3 button{
        width: 300px;
        height: 35px;
        margin-left: 30px;
        /* 定位登录按钮 */
        position: absolute;
        bottom: 20px;
        
        background-color: rgb(219, 34, 46);
        border: none;
        color: white;
        font-size: 20px;
    }
    
    /* 设置第三方登录 */
    #content #login_page #div4{
        height: 50px;
        
        /* 设置a标签的行高为父标签高度来实现垂直居中 */
        line-height: 50px;
        font-size: 10px;
        color: rgba(200, 200, 200, 0.9);
        
    }
    /* 设置a1标签的的布局 */
    #content #login_page #div4 #a1{
        margin-left: 30px;
        margin-right: 15px;
        color: rgb(89, 89, 89);
        font-size: 13px;
        text-decoration: none;
        padding-left: 25px;
        background: url(../img/qq.png) no-repeat 0, center white;
    }
    
    #content #login_page #div4 #a2{
        margin-left: 5px;
        color: rgb(89, 89, 89);
        font-size: 13px;
        text-decoration: none;
        padding-left: 25px;
        background: url(../img/weixin.png) no-repeat 0, center white;
    }
    
    
    #content #login_page #div4 #a3{
        position: absolute;
        right: 20px;
        
        color: rgb(165, 19, 23);
        font-size: 13px;
        text-decoration: none;
        padding-left: 25px;
        background: url(../img/right.png) no-repeat 0, center 0;
    }
    
    /* 设置三个a标签的初始状态值 */
    #content #login_page #div4 #a1:hover{
        color: red;
        text-decoration: underline;
    }
    
    #content #login_page #div4 #a2:hover{
        color: red;
        text-decoration: underline;
    }
    
    #content #login_page #div4 #a3:hover{
        text-decoration: underline;
    }
    
    
    /* =========================底部布局============================= */
    #footer{
        height: 105px;
    }
    /* 设置footer里面的布局 */
    #footer div{
        height: 50px;
        /* 设置垂直方向居中 */
        line-height: 50px;
        /* 设置水平方向居中 */
        text-align: center;
        font-size: 13px;
        color: rgba(89, 89, 89, 0.6);
    }
    
    #footer div a{
        margin-left: 10px;
        margin-right: 10px;
        color: rgb(89, 89, 89);
        text-decoration: none;
    }
    /* 设置a标签鼠标悬停状态 */
    #footer div a:hover{
        color: red;
        text-decoration: underline;
    }
    
    #footer p{
        color: rgb(89, 89, 89);
        font-size: 12px;
        text-align: center;
    }
    

    三、知识点总结

    注意:不管写任何代码要勤写注释,不同的部分要分块,怎么样可以让后器代码优化更加简单。
    1、通配符

    {
    /
    消除默认的margin值 /
    margin: 0;
    /
    消除默认的padding值 /
    padding: 0;
    /
    让所有的标签的字标签都相对自己定位 /
    position: relative;
    }
    利用
    通配符来设置所有标签的margin和padding属性,position属性用于定位。

    2、相对定位会让标签脱流
    3、内容垂直居中

    #header #top div{
    width: 292px;
    height: 60px;
    /* background-color: green; /
    /
    相对定位会让标签脱流 /
    position: absolute;
    left: 188px;
    /
    垂直居中 /
    top: 50%;
    margin-top: -30px;
    /
    标签高度 */
    line-height: 60px;
    }

    4、设置背景图片

    添加背景图
    background:url(图片地址) repeat/no-repeat(是否平铺) x坐标 y坐标 背景颜色;
    x,y:两个坐标对应的值,除了可以设置数字以外,还可以设置center,让背景图在x或y坐标方向上居中*/
    padding-left: 22px;
    background: url(../img/q-icon.png) no-repeat 0 center white;

    5、标签中是文字,一般都可以用text-align: center;让文字在标签中居中
    6、去掉a标签的下划线

    #header #bottom a{
    /* 去掉下划线 /
    text-decoration: none;
    /
    改变字体颜色 */
    color: rgb(70,70,70);
    }

    7、设置字体大小

    #content #login_page #div2{
    height: 60px;
    /* background-color: white; /
    color: rgba(220, 220,220, 0.6);
    /
    设置字体粗细,取值范围在100到900依次增大 */
    font-weight: 100;
    }

    8、改变标签成为焦点时的状态

    /* 设置按钮成为焦点的状态 /
    #content #login_page #div2 button:focus{
    color: #FF0000;
    /
    按钮成为焦点时的默认效果outline */
    outline: none;
    }

    9、使用伪类选择器设置鼠标悬停在鼠标上时的初始状态

    #header #bottom a:hover{
    /* 鼠标悬停加上下划线 */
    text-decoration: underline;
    }

    相关文章

      网友评论

          本文标题:2018-11-01day4-京东登录静态页面

          本文链接:https://www.haomeiwen.com/subject/erkqxqtx.html