CSS achieves the effect of two elements blending (sticky effect)

CSS achieves the effect of two elements blending (sticky effect)

I remember that a few years ago, there was an interesting round button in the lower left corner of the mobile version of Taobao. After clicking it, several small buttons would appear, and the appearance animation was very interesting. Later I learned that this effect was called the "sticky" effect, as shown in the picture:

So what attributes are used for this effect? The answer is that the filter:blur() attribute and the filter:contrast() attribute are used together.

<style>
    body{
        margin: 0;
        padding: 0;
    }
    .box{
        position: relative;
        width: 500px;
        height: 500px;
        filter:contrast(20);
        /* The background color must be a solid background color, otherwise the edges of the two elements will be blurred*/
        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>

The final effect is as shown below:

This is the end of this article about how to use CSS to achieve the effect of blending two elements (viscous effect). For more information about how to blend two elements using CSS, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Vue monitoring properties and calculated properties

>>:  Centos6.5 glibc upgrade process introduction

Recommend

Webpack loads css files and its configuration method

webpack loads css files and its configuration Aft...

How to use the Linux md5sum command

01. Command Overview md5sum - Calculate and verif...

Two ideas for implementing database horizontal segmentation

introduction With the widespread popularity of In...

Detailed explanation of the use of Vue mixin

Table of contents Use of Vue mixin Data access in...

This article will show you how JavaScript garbage collection works

Table of contents 1. Overview 2. Memory Managemen...

Linux system file sharing samba configuration tutorial

Table of contents Uninstall and install samba Cre...

Style trigger effect of web page input box

<br />This example mainly studies two parame...

Detailed explanation of deploying MySQL using Docker (data persistence)

This article briefly describes how to use Docker ...

React hooks pros and cons

Table of contents Preface advantage: shortcoming:...

A brief discussion on the implementation of fuzzy query using wildcards in MySQL

In the MySQL database, when we need fuzzy query, ...

How to modify the root password of mysql under Linux

Preface The service has been deployed on MySQL fo...

How to implement adaptive container with equal aspect ratio using CSS

When developing a mobile page recently, I encount...

Three ways to forward linux ssh port

ssh is one of the two command line tools I use mo...

Implementation of css transform page turning animation record

Page turning problem scenario B and C are on the ...