登录界面---油管大佬

1.这是我见过最好看的登录界面了

2.点击输入文本,Username会上移,下面有一道线划过,登录按钮被覆盖后颜色会划过。内含js代码
3.HTML代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
    
    <form action="index.html" class="login-form">
        <h1>Login</h1>

        <div class="txtb">
            <input type="text">
            <span data-placeholder="Username"></span>
        </div>

        <div class="txtb">
            <input type="password">
            <span data-placeholder="password"></span>
        </div>

        <input type="submit" class="logbtn" value="Login">

        <div class="bottom-text">
            Don't have account? <a href="#">Sign up </a>
        </div>
    </form>

    <script type="text/javascript">
        $(".txtb input").on("focus",function(){
            $(this).addClass("focus");
        });
        
        $(".txtb input").on("blur",function(){
            if($(this).val()=="")
                $(this).removeClass("focus");
        });
    </script>


</body>
</html>
4.CSS代码
*{
    /* 外边距 */
    margin: 0;
    /* 内边距 */
    padding: 0;
    /* 文本没有线 */
    text-decoration: none;
    /* 字体家族 */
    font-family: montserrat;
    /* border-box 告诉浏览器去理解你设置的边框和内边距的值是包含在width内的 */
    box-sizing: border-box;
}
body{
    /* 调整背景颜色 */
    min-height: 100vh;
    background-image: linear-gradient(120deg,#3498db,#8e44ad);

}

.login-form{
    width: 360px;
    background: #f1f1f1;
    height: 580px;
    /* 高度内边距为80,左右边距为40 */
    padding: 80px 40px;
    /* 定义圆角 */
    border-radius: 10px;
    position: absolute;
    /* 以下三个是居中 */
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
}

.login-form h1{
    text-align: center;
    /* 下外边距 */
    margin-bottom: 60px;
}

.txtb{
    border-bottom: 2px solid #adadad;
    position: relative;
    /* 上下外边距为30,左右为0 */
    margin: 30px 0;
}

.txtb input{
    font-size: 15px;
    color: #333;
    border: none;
    width: 100%;
    outline: none;
    background: none;
    /* 上下内边距为0,左右为5 */
    padding: 0 5px;
    height: 40px;
}

.txtb span::before{
    content: attr(data-placeholder);
    position: absolute;
    top: 50%;
    left: 5px;
    color: #adadad;
    /* Username上升50% */
    transform: translateY(-50%);
    /* 设置元素的堆叠顺序 */
    z-index: -1;
    transition: .5s;
}

.txtb span::after{
    /* 每一个网页元素都有一个display属性,div元素,它的默认display属性值为“block”,
    成为“块级”元素(block-level);而span元素的默认display属性值为“inline”,称为“行内”元素。
    块状元素会单独占据一样,其他元素跟他在同一行的会回被迫换行,挤到下答一行那里去 */
    display: block;
    content: '';
    position: absolute;
    width: 0%;
    height: 2px;
    background: linear-gradient(120deg,#3498db,#8e44ad);
    transition: .5s;
}

.focus + span::before{
    top: -5px;
}

.focus + span::after{
    width: 100%;
}

.logbtn{
    display: block;
    width: 100%;
    height: 50px;
    border: none;
    background: linear-gradient(120deg,#3498db,#8e44ad,#3498db);
    background-size: 200%;
    color: #fff;
    outline: none;
    /* 鼠标放上面会变成小手 */
    cursor: pointer;
    transition: .5s;
}

.logbtn:hover{
    background-position: right;
}

.bottom-text{
    margin-top: 60px;
    text-align: center;
    font-size: 13px;
}
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值