Sample code for CSS dynamic loading bar effect

Sample code for CSS dynamic loading bar effect

Using the knowledge of CSS variables, I will directly post the code and the comments I added

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Show a CSS dynamic loading bar</title>
    <style>
      /* Using CSS variables */
      .flex {
        display: flex;
        list-style: none;
        /* Set the li elements to be arranged horizontally */
      }
 
      .loading {
        width: 200px;
        height: 200px;
      }
 
      .loading>li {
        /* We define a CSS variable for each inline element of the li element -- line-index has different sizes*/
        /* At this time, set an animation delay variable--time after calculation calc */
        --time: calc((var(--line-index) - 1) * 200ms);
        border-radius: 3px;
        width: 6px;
        height: 30px;
        background-color: #f66;
        /* The animations are all the same, but they start at different times, which results in this effect*/
        animation: beat 1.5s ease-in-out var(--time) infinite;
 
      }
 
      .loading>li+li {
        margin-left: 5px;
      }
 
      @keyframes beat {
 
        0%,
        100% {
          transform: scaleY(1);
        }
 
        50% {
          transform: scaleY(.5);
        }
      }
    </style>
  </head>
  <body>
    <ul class="loading flex">
      <li style="--line-index: 1;"></li>
      <li style="--line-index: 2;"></li>
      <li style="--line-index: 3;"></li>
      <li style="--line-index: 4;"></li>
      <li style="--line-index: 5;"></li>
      <li style="--line-index: 6;"></li>
    </ul>
  </body>
</html>

See the effect

This is the end of this article about the CSS dynamic loading bar source code. For more relevant CSS dynamic loading bar content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  Summary of several APIs or tips in HTML5 that cannot be missed

>>:  Several ways to schedule backup of MySQL database (comprehensive)

Recommend

Understand the basics of Navicat for MySQL in one article

Table of contents 1. Database Operation 2. Data T...

Scary Halloween Linux Commands

Even though it's not Halloween, it's wort...

How to install Maven automatically in Linux continuous integration

Unzip the Maven package tar xf apache-maven-3.5.4...

Summary of MySql import and export methods using mysqldump

Export database data: First open cmd and enter th...

Why MySQL does not recommend using null columns with default values

The answer you often hear is that using a NULL va...

Detailed explanation of virtual DOM and diff algorithm in react

The role of virtual DOM First of all, we need to ...

Using JavaScript to implement carousel effects

This article shares the specific code for JavaScr...

MySQL configuration SSL master-slave replication

MySQL5.6 How to create SSL files Official documen...

How to reset the root password of Mysql in Windows if you forget it

My machine environment: Windows 2008 R2 MySQL 5.6...

Teach you how to subcontract uniapp and mini-programs (pictures and text)

Table of contents 1. Mini Program Subcontracting ...

Example explanation of MySQL foreign key constraints

MySQL's foreign key constraint is used to est...

jQuery implements a simple carousel effect

Hello everyone, today I will share with you the i...

Seven ways to implement array deduplication in JS

Table of contents 1. Using Set()+Array.from() 2. ...