CSS案例练习-02仿掘金登陆框

316 阅读1分钟

02-仿掘金登陆框

效果:

1.HTML代码

index.html:

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

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- 引入初始化样式  reset.css -->
    <link rel="stylesheet" href="css/reset.css" />
    <!-- 引入本页自定义样式  index.css-->
    <link rel="stylesheet" href="css/index.css" />
    <title>掘金登录框</title>
</head>

<body>
    <div class="login">
        <!-- 登录标题 start -->
        <h1>账密登录</h1>
        <!-- 登录标题 end -->
        <!-- 账号密码输入框 start -->
        <input type="text" class="user" placeholder="邮箱/手机号(国际号码加区号)" />
        <input type="text" class="pwd" placeholder="请输入密码" />
        <!-- 账号密码输入框 end -->
        <!-- 登录按钮 start -->
        <button>登录</button>
        <!-- 登录按钮 end -->
        <!-- 手机登录、忘记密码 start -->
        <div class="login-line">
            <ul>
                <li><a href="#">手机登录</a></li>
                <li><a href="#">忘记密码</a></li>
            </ul>
        </div>
        <!-- 手机登录、忘记密码 end -->
        <!-- 其他方式登录 start -->
        <div class="other">
            <span><a href="#"><img src="/images/wb.svg" alt="" /></a
        ></span>
            <span><img src="/images/wx.svg" alt="" /></span>
            <span><img src="/images/github.svg" alt="" /></span>
        </div>
        <!-- 其他方式登录 end -->
        <!-- 接受协议 start -->
        <div class="accept">
            注册登录即表示同意&nbsp;<span><a href="#">用户协议、隐私政策</a></span>
        </div>
        <!-- 接受协议 end -->
    </div>
</body>

</html>

2.CSS代码

1.reset.css

/* 初始化样式 */

body {
    background-color: #004cd7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

li {
    list-style: none;
}

input {
    outline: none;
}

a {
    text-decoration: none;
}

button {
    border: none;
}

2.index.css

/* 整个登录框 */

.login {
    margin: 360px auto;
    padding: 28px 23px;
    width: 318px;
    height: 367px;
    background-color: #fff;
    border-radius: 3px;
}


/* 登录框标题 */

.login h1 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 27px;
}


/* 账号密码输入框 */

.login input {
    padding-left: 10px;
    width: 270px;
    height: 40px;
    font-size: 14px;
    border: 1px solid #e9e9e9;
}

.login .user {
    margin-bottom: 10px;
}


/* 登录按钮 */
.login button {
    margin: 14px 0;
    width: 270px;
    height: 40px;
    background-color: #007fff;
    color: #fff;
    font-size: 14px;
    border-radius: 3px;
    cursor: pointer;
}


/* 手机登录、忘记密码 */

.login .login-line li a {
    font-size: 14px;
    color: #007fff;
}

.login .login-line li {
    float: left;
}

.login .login-line li:first-child {
    margin-right: 160px;
}


/* 其他登录方式 */

.login .other span {
    float: left;
    margin: 14px 22px;
    padding-top: 8px;
    width: 45px;
    height: 45px;
    text-align: center;
    border-radius: 50%;
    background-color: #f4f8fb;
    /* background-color: pink; */
}

.login .other span img {
    width: 30px;
    height: 30px;
}


/* 同意协议 */

.login .accept {
    font-size: 13px;
    color: #767676;
}

.login .accept span a {
    color: #007fff;
}