CSS實現兩個元素相融效果(粘滯效果)

記得前幾年手機版淘寶左下角有個狠有意思的圓形按鈕,點擊後會出現幾個小按鈕,而且出場動畫頗有意思,後面才知道這種效果叫「粘滯」效果,如圖:
粘滯按鈕效果css

那這種效果到底用了什麼屬性呢?答案是主要用了filter:blur()屬性,及filter:contrast()屬性配合動畫

<style>
    body{
        margin: 0;
        padding: 0;
    }
    .box{
        position: relative;
        width: 500px;
        height: 500px;
        filter: contrast(20);
        /* 背景色必定要爲實底色,不然兩個元素邊緣會有模糊效果 */
        background-color: #fff;
    }
    .circle-big{
        position: absolute;
        top: 20px;
        left: 100px;
        width: 100px;
        height: 100px;
        border-radius: 50%;
        filter: blur(6px);
        box-sizing: border-box;
        animation: toRight 3s ease-out infinite;
        background-color: #333;
    }
    .circle-small{
        position: absolute;
        top: 35px;
        left: 220px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        filter: blur(6px);
        box-sizing: border-box;
        animation: toLeft 3s ease-out infinite;
        background-color: #FFFC00;
    }
    @keyframes toRight{
        50%{
            left: 150px;
        }
    }
    @keyframes toLeft{
        50%{
            left: 150px;
        }
    }
</style>

<div class="box">
    <div class="circle-big"></div>
    <div class="circle-small"></div>
</div>

最終效果如圖:
css融合效果spa