css边缘融合效果 模糊/对比度 filter blur/contrast

技术 · 2023-07-16
css边缘融合效果 模糊/对比度 filter blur/contrast

本例演示了filter:blur()filter:contrast()的用法,实现两个盒子融合的效果。
html部分:

    <div class="container">
        <div class="box1"></div>
        <div class="box2"></div>
    </div>

css样式:

        body{
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            padding: 0;
            margin: 0;
            background: #111;
        }
        .container{
            display: flex;
            align-items: center;
            justify-content: center;
            filter: contrast(50);
            background: #111;
            width: 600px;
            height: 600px;
        }
        .box1,.box2{
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: #fff;
            filter: blur(25px);
        }
        .box1{
            animation: r1 .8s ease-in-out infinite alternate;
        }
        .box2{
            animation: r2 .8s ease-in-out infinite alternate;
        }
        @keyframes r1{
            from{
                transform: translateX(142px) rotate(-45deg);

            }
            to{
                transform: translateX(-80px) rotate(45deg);
            }
        }
        @keyframes r2{
            from{
                transform: translateX(-142px) rotate(45deg);
            }
            to{
                transform: translateX(80px) rotate(-45deg);
            }
        }
css
Theme Jasmine by Kent Liao