用html 和 css 写个简洁的登录框

前言:

这是作业的一部分,写了挺久的。完成了html 和 css 的部分,因为用到了css3 兼容性可能不是这么好,还可以再改进。

 

效果:

代码:

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录界面</title>
    <style>
        input,
        td,
        table,
        th {
            padding: 0px;
            margin: 0px;
        }

        table {
            width: 425px;
            margin: 100px auto;
            border: 2px solid #9dc45f;
            /* 如果把border-collapse 设为 collapse ,那么就与border-radius 不兼容了 */
            /* 也因为设了separate 导致表格的顶部多了些空格 */
            border-collapse: separate;
            text-align: center;
            font-size: 12px;
            border-radius: 8px;
            /* 盒子阴影 ,用来填充因为border-collapse:spearate 带来的“边框” */
            box-shadow: 0px 64px 1px #9dc45f inset;
        }
        td{
            /* 设每个td的高度都为30px , 及表格的行高为30px */
            height: 30px;
        }
        /* 设置第一个tr 的样式 */
        tr:nth-child(1) {
            height: 68px;
            background-color: #9dc45f;
            font-size: 16px;
            color: white;
        }

        /* 设id为 text 的 td元素 */
        #text {
            position: relative;
            vertical-align: bottom;
        }
        /* 设置复选框的样式 */
        #text input{
            vertical-align: middle;
            margin-top:-2px;
            margin-bottom: 1px;
            width: 12px;
            height: 12px;
            appearance: none;
            -webkit-appearance: none;
            opacity: 0;
            outline: none;
        }
        #text label{
            position: absolute;
            left: 161px;
            top: 15px;
            z-index: -1;
            width: 12px;
            height: 12px;
            border: 1px solid black;
        }
        #text input:checked+label::after{
            content: "";
            position: absolute;
            left: 4px;
            top: -3px;
            width: 5px;
            height: 12px;
            border-right: 1px solid black;
            border-bottom: 1px solid black;
            transform: rotate(45deg);
        }
        /* 设置复选框样式结束 */

        /* 设提交按键和重置按键的样式 */
        .btn {
            width: 96px;
            height: 27px;
            background-color: #9dc45f;
            border-width: 0px;
            color: white;
            border-radius: 5px;
        }
    </style>
</head>

<body>
    <table cellpadding = "2">
        <tr>
            <th>账号密码登录</th>
        </tr>

        <tr>
            <td>
                <form action="">
                    账号:<input type="text">
                </form>
            </td>
        </tr>

        <tr>
            <td>
                <form action="">
                    密码:<input type="password">
                </form>
            </td>
        </tr>

        <tr>
            <td id="text">
                <input type="checkbox" id = "Select">
                <label for="Select"></label>
                下次请自动登录
            </td>
        </tr>

        <tr>
            <td>
                <input type="submit" value="登录" class="btn">
            </td>
        </tr>

        <tr>
            <td>
                <input type="reset" class="btn">
            </td>
        </tr>

    </table>

</body>

</html>

 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值