This is my seventh day of the Gwen Challenge

First look at the effect:

Watch more videos

Implementation:

  1. Add labels to the bottom box, then directly violence to add 10 bubble labels:
 <div class="kuang">
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
    </div>
Copy the code
  1. Add bottom box style, width and height:
.kuang{
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -10;
            background-image: linear-gradient(180deg.rgb(78.168.241),rgb(37.91.241));

        }
Copy the code

position: fixed; Position relative to the browser window. background-image: linear-gradient(180deg,rgb(78, 168, 241),rgb(37, 91, 241)); Gradient background color.

  1. Add bubble style:
.bubble{
            position: absolute;
            border-radius: 50%;
            border: 2px solid #fff;
            box-shadow: inset 0 0 8px  #fff;
            animation: flutter 10s infinite;
            opacity: 0;
        }
Copy the code

position: absolute; Absolute positioning. border-radius: 50%; The Angle of the four corners of an element. box-shadow: inset 0 0 8px #fff; The shadow. animation: flutter 10s infinite; Animation, 10s, repeat.

  1. Define animation:
 @keyframes flutter {
            0%{
                transform: translateX(0);
                bottom: -100px;
                opacity: 1;
            }
            50%{
                transform: translateX(100px);
                opacity: 0.5;
            }

            
            100%{
                transform: translateX(0px);
                bottom: 100%;
                opacity: 0; }}Copy the code

Bottom Distance between the bubble and the bottom. Transform: Offset from translateX () horizontally. opacity: ; Transparency. 1 indicates impenetrability and 0 indicates complete transparency.

  1. Define width, height, location, etc., for each bubble:

Such as:

 .bubble:nth-child(1) {left: -10%;
            width: 50px;
            height: 50px; 
            animation-duration: 9s;
            animation-delay: 0.1 s;
        }
Copy the code

Other bubble set directly look at the source code below, this can see what effect their own value; ,

animation-duration: 9s; The time it takes for an animation to complete. Animation – delay: 0.1 s; The animation starts playing after a delay of a few seconds.

Complete code:

<! DOCTYPEhtml>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="Width = device - width, initial - scale = 1.0">
    <title>Document</title>
    <style>* {margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
 
        .kuang{
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -10;
            background-image: linear-gradient(180deg.rgb(78.168.241),rgb(37.91.241));

        }
        .bubble{
            position: absolute;
            border-radius: 50%;
            border: 2px solid #fff;
            box-shadow: inset 0 0 8px  #fff;
            animation: flutter 10s infinite;
            opacity: 0;
        }
        @keyframes flutter {
            0%{
                transform: translateX(0);
                bottom: -100px;
                opacity: 1;
            }
            50%{
                transform: translateX(100px);
                opacity: 0.5;
            }

            
            100%{
                transform: translateX(0px);
                bottom: 100%;
                opacity: 0; }}.bubble:nth-child(1) {left: -10%;
            width: 50px;
            height: 50px; 
            animation-duration: 9s;
            animation-delay: 0.1 s;
        }
        .bubble:nth-child(2) {left: 15%;
            width: 20px;
            height: 20px;
            animation-duration: 6s;
            animation-delay: 1.5 s;

        }
        .bubble:nth-child(3) {left: 20%;
            width: 60px;
            height: 60px;
            animation-duration: 10s;
            


        }
        .bubble:nth-child(4) {left: 30%;
            width: 30px;
            height: 30px;
            animation-duration: 5.5 s;
            animation-delay: 1.5 s;

        }
        .bubble:nth-child(5) {left: 40%x;
            width: 50px;
            height: 50px;
            animation-duration: 12s;
            


        }
        .bubble:nth-child(6) {left: 50%;
            width: 20px;
            height: 20px;
            animation-duration: 6s;
            animation-delay: 1s;

        }
        .bubble:nth-child(7) {left: 60%;
            width: 40px;
            height: 40px;
            animation-duration: 8s;
            animation-delay: 1s;

        }
        .bubble:nth-child(8) {left: 65%;
            width: 60px;
            height: 60px;
            animation-duration: 15s;
          
        }
        .bubble:nth-child(9) {left: 80%;
            width: 55px;
            height: 55px;
            animation-duration: 9s;
            animation-delay: 0.5 s;
            
        }
        .bubble:nth-child(10) {left: 100%;
            width: 40px;
            height: 40px;
            animation-duration: 12s;

        }
    </style>
</head>
<body>
    <div class="kuang">
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
        <div class="bubble"></div>
    </div>
    
</body>
</html>
 
Copy the code

Conclusion:

~ ~ ~ see you next time

Other articles ~ : Simple clock special effects HTML + CSS + JS Cyberpunk button HTML + CSS Responsive card Hover effect HTML + CSS Water loading animation HTML + CSS Navigation bar scrolling gradient effect HTML + CSS Page turning HTML + CSS 3D stereo album HTML + CSS Colorful streamer button HTML + CSS Remember some CSS properties summary (a) Sass summary note…… , etc.