html加jq制作的登录界面

本文介绍了一个简单的登录界面的设计与实现过程,包括HTML结构布局、CSS样式美化及使用jQuery进行基本交互效果的添加。该登录界面能够响应窗口大小变化并调整位置。

登录界面

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">
    <title>Document</title>
    <link rel="stylesheet" href="login.css">
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>

<body class="body1">
    <div class="box">
        <p class="p1">请输入账号信息</p>
        <form>
            <p class="p2">输入账号</p>
            <input type="text">
            <p class="p3">输入密码</p>
            <input type="password"><br>
            <input type="button" class="bt1" value="提交">
        </form>
    </div>
</body>

</html>

css

* {
    margin: 0;
    padding: 0;
    transition: all 1s;
}

.body1 {
    background: url(login_bg.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    width: 100%;
}

.box {
    width: 400px;
    min-width: 300px;
    margin: auto;
    margin-top: 200px;
    text-align: center;
    background-color: rgb(192, 194, 197);
    opacity: 0.9;
    padding-bottom: 20px;
}

.p1 {
    width: 100%;
    height: 30px;
    background: linear-gradient(to right, rgba(56, 1, 1, 0.726), rgba(1, 1, 58, 0.637));
    text-align: center;
    padding-top: 10px;
    color: white;
}

.p2 {
    margin-top: 15px;
    margin-bottom: 8px;
    color: rgb(18, 18, 19);
}

.p3 {
    margin-top: 5px;
    margin-bottom: 8px;
    color: rgb(18, 18, 19);
}

.box input {
    width: 80%;
    height: 23px;
    outline: none;
}

.bt1 {
    margin-top: 30px;
    width: 200px;
    background: linear-gradient(to left, rgba(56, 1, 1, 0.726), rgba(1, 1, 58, 0.637));
    color: white;
    font-size: 12px;
}

.box input:focus {
    background-color: wheat;
}

.bt1:hover {
    transform: scale(1.1, 1.1);
}

javascript

  //让主体在垂直方向
        var y = $(window).height();
        var x = $(".box").height();
        var marginTop = (y - x) / 2;
        $(".box").css("margin-top", marginTop);
        //监听
        $(window).on("resize", function() {
            var y = $(window).height();
            var x = $(".box").height();
            var marginTop = (y - x) / 2;
            $(".box").css("margin-top", marginTop);
        })

最终效果(做了两种样式)

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值