CSS实现登录表单毛玻璃效果

效果图

在这里插入图片描述

html代码

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="box">
        <form action="#" class="login-form">
            <h2>登录</h2>
            <input type="text" name="username" id="" placeholder="用户名">
            <input type="text" name="password" id="" placeholder="密码 ">
            <button type="submit">登录</button>
        </form>
    </div>
</body>

</html>

CSS代码

* {
    margin: 0;
    padding: 0;
}

.box {
    display: flex;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: url(https://coolbackgrounds.io/images/unsplash/josh-bean-medium-9501ba9f.jpg) no-repeat fixed;
    background-size: cover;
}

.login-form {
    display: flex;
    position: relative;
    width: 240px;
    height: 220px;
    flex-direction: column;
    padding: 40px;
    text-align: center;
    z-index: 1;
    background: inherit;
    border-radius: 18px;
    overflow: hidden;
}

.login-form::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    width: calc(100% + 20px);
    /* + 两边各有一个空格  否则 无效*/
    height: calc(100% + 20px);
    background: inherit;
    box-shadow: 0 0 0 200px rgba(255, 255, 255, .2) inset;
    z-index: -1;
    filter: blur(6px);
    overflow: hidden;
}

.login-form h2 {
    font-size: 18px;
    font-weight: 400;
    color: #3d5245;
}

.login-form input,
.login-form button {
    margin: 6px 0;
    height: 36px;
    background-color: rgba(255, 255, 255, .3);
    border: none;
    border-radius: 4px;
    padding: 0 14px;
    color: #3d5245;
}

.login-form input::placeholder {
    color: #3d5245;
}

.login-form button {
    position: relative;
    margin-top: 24px;
    background-color: rgba(57, 88, 69, .4);
    color: #ffffff;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s;
}

.login-form button:hover {
    background-color: rgba(12, 88, 38, 0.67);
}

.login-form button::before,
.login-form button::after {
    content: '';
    display: block;
    width: 80px;
    height: 100%;
    background-color: rgba(179, 255, 210, .5);
    opacity: 0.5s;
    position: absolute;
    left: 0;
    top: 0;
    transform: skewX(-15deg);
    filter: blur(30px);
    overflow: hidden;
    transform: translateX(-100px);
}

.login-form button::after {
    width: 40px;
    background-color: rgba(179, 255, 210, .3);
    left: 60px;
    filter: blur(5px);
    opacity: 0;
}

.login-form button:hover::before {
    transition: all 1s;
    transform: translateX(320px);
    opacity: 0.7;
}

.login-form button:hover::after {
    transition: all 1s;
    transform: translateX(320px);
    opacity: 1;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值