First day of work after the holidays. Wake up in the morning, huh? Ah… ? What… ? What is this? Who am I? What class?

However goose, or was deliberately set last night’s eight alarm clock ⏰ wake up, winter morning get up difficulty… Must have everyone heart experience 😭, holding ten thousand reluctant to get up early came to the office, or familiar with the environment, or familiar with the taste of…

Also, familiar task requirements πŸ˜‚.

Today’s first task is to write a login page, the boss gave me a (Chao) examination (XI) case, you can click the link to see. Well, this login page is really simple and generous, especially its bubble background. At first thought, it should be a dynamic picture, but when I opened the review element, I found that it was written in code, which aroused the curiosity of my baby. So I tried to write a login page with bubble background.

emm… Why are uploaded giFs always so small?

(You can imagine these background bubbles rising 😭)

It takes a little bit of simple code to do this,

First let’s define 10 li list tags. I’m using the VUE framework:

<ul class="bg-bubbles">
    <li v-for="i in 10" :key="i"></li>
</ul>
Copy the code

Styles are written in less:

.bg-bubbles {
    position: absolute;
    // Fill the screen with bubble background;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    // If the element content exceeds the given width and height, overflow attributes can determine whether to display behavior such as scroll bars;
    overflow: hidden;
    li {
      position: absolute;
      // Bottom is set to create the effect of bubbles popping up from the bottom of the page;
      bottom: -160px;
      // Default bubble size;
      width: 40px;
      height: 40px;
      background-color: rgba(255.255.255.0.15);
      list-style: none;
      // Use custom animations to make bubbles fade, rise, and tumble;
      animation: square 15s infinite;
      transition-timing-function: linear;
      // Set each bubble to a different position, size, transparency and speed to create a sense of hierarchy;
      &:nth-child(1) {
        left: 10%;
      }
      &:nth-child(2) {
        left: 20%;
        width: 90px;
        height: 90px;
        animation-delay: 2s;
        animation-duration: 7s;
      }
      &:nth-child(3) {
        left: 25%;
        animation-delay: 4s;
      }
      &:nth-child(4) {
        left: 40%;
        width: 60px;
        height: 60px;
        animation-duration: 8s;
        background-color: rgba(255.255.255.0.3);
      }
      &:nth-child(5) {
        left: 70%;
      }
      &:nth-child(6) {
        left: 80%;
        width: 120px;
        height: 120px;
        animation-delay: 3s;
        background-color: rgba(255.255.255.0.2);
      }
      &:nth-child(7) {
        left: 32%;
        width: 160px;
        height: 160px;
        animation-delay: 2s;
      }
      &:nth-child(8) {
        left: 55%;
        width: 20px;
        height: 20px;
        animation-delay: 4s;
        animation-duration: 15s;
      }
      &:nth-child(9) {
        left: 25%;
        width: 10px;
        height: 10px;
        animation-delay: 2s;
        animation-duration: 12s;
        background-color: rgba(255.255.255.0.3);
      }
      &:nth-child(10) {
        left: 85%;
        width: 160px;
        height: 160px;
        animation-delay: 5s; }}// Custom square animation;
    @keyframes square {
      0% {
        opacity: 0.5;
        transform: translateY(0px) rotate(45deg);
      }
      25% {
        opacity: 0.75;
        transform: translateY(-400px) rotate(90deg)}50% {
        opacity: 1;
        transform: translateY(-600px) rotate(135deg);
      }
      100% {
        opacity: 0;
        transform: translateY(-1000px) rotate(180deg); }}}Copy the code

The background color of the outermost parent container is:

background: linear-gradient(to bottom right, #50A3A2.#53E3A6);
Copy the code

At this point, a bubble background is complete. Looking back, it is not difficult, but also more and more people feel the charm and power of CSS animation ☺️.

If you like this article, you might as well click a like or follow, this will be my greater motivation.

The front road is long, hope and your mutual encouragement πŸ’ͺ.