欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CSS3: 毛玻璃效果和按钮反光

程序员文章站 2024-02-25 14:34:33
...

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>
        html,body{
            margin: 0;
            font-family: Arial, Helvetica, sans-serif;
        }

        .container{
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: url(http://47.103.18.122/yinlei/meimei.jpg) fixed no-repeat;
            background-size: cover;
        }

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

        .login-form::before{
            content: "";
            width: calc(100% + 20px);
            height: calc(100% + 20px);
            background: inherit;
            box-shadow: inset 0 0 0 200px rgba(255,255,255,.25); 
            position: absolute;
            top: -10px;
            left: -10px;
            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;
            border: none;
            background: rgba(255,255,255,.3);
            border-radius: 4px;
            padding: 0 14px;
            color: #3d5245;
        }

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

        .login-form button{
            margin-top: 24px;
            color: white;
            position: relative;
            overflow: hidden;
            cursor: pointer;
            transition: .4s;
        }

        .login-form button:hover{
            background:rgba(22, 160, 133,.3);
        }

        .login-form button::before, .login-form button::after{
            content: "";
            display: block;
            width: 80px;
            height: 100%;
            background:rgba(26, 188, 156,.8);
            opacity: .8;
            position: absolute;
            left: 0;
            top: 0;
            transform: skewX(-15deg);
            filter: blur(30px);
            overflow: hidden;
            transform: translateX(-100px);
        }

        .login-form button::after {
            width: 40px;
            background: rgba(46, 204, 113,.8);
            left: 60px;
            filter: blur(5px);
            opacity: 0;
        }

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

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

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

毛玻璃主要是:

      .login-form::before{
            content: "";
            width: calc(100% + 20px);
            height: calc(100% + 20px);
            background: inherit;
            box-shadow: inset 0 0 0 200px rgba(255,255,255,.25); 
            position: absolute;
            top: -10px;
            left: -10px;
            z-index: -1;
            filter: blur(6px);
            overflow: hidden;
        }

 

相关标签: 大前端