search
HomeWeb Front-endCSS TutorialImplementation of several common loding effects

This time we will talk about several common loding effect implementations, and what points need to be paid attention to when implementing the loding effect. The following is a practical case, let's take a look at it together.

<html>
       <head>
              <meta charset="UTF-8">
              <title>Loading</title>
              <link rel="stylesheet" type="text/css" href="loading.css">
              <style>
                     .loader {
                            float: left;
                     }
                    
                     .loader {
                            position: relative;
                            width: 5rem;
                            height: 5rem;
                     }
                    
                     .loader.small {
                            -webkit-transform: scale(.5);
                            transform: scale(.5);
                     }
                    
                     .loader.circle-line,
                     .loader.circle-round {
                            height: 5rem;
                     }
                     /*circle-line*/
                    
                     .loader.circle-line span {
                            position: absolute;
                            display: inline-block;
                            width: 1.5rem;
                            height: .5rem;
                            border-top-left-radius: .25rem;
                            border-bottom-left-radius: .25rem;
                            background: #1ABC9C;
                            opacity: .05;
                            -webkit-animation: circle-line 1s ease infinite;
                            animation: circle-line 1s ease infinite;
                     }
                    
                     .loader.circle-line span:nth-child(1) {
                            top: 50%;
                            left: 0;
                            margin-top: -.25rem;
                            -webkit-animation-delay: .13s;
                            animation-delay: .13s;
                     }
                    
                     .loader.circle-line span:nth-child(2) {
                            top: 1rem;
                            left: .5rem;
                            -webkit-transform: rotate(45deg);
                            transform: rotate(45deg);
                            -webkit-animation-delay: .26s;
                            animation-delay: .26s;
                     }
                    
                     .loader.circle-line span:nth-child(3) {
                            left: 50%;
                            top: .5rem;
                            margin-left: -.75rem;
                            -webkit-transform: rotate(90deg);
                            transform: rotate(90deg);
                            -webkit-animation-delay: .39s;
                            animation-delay: .39s;
                     }
                    
                     .loader.circle-line span:nth-child(4) {
                            right: .5rem;
                            top: 1rem;
                            -webkit-transform: rotate(145deg);
                            transform: rotate(145deg);
                            -webkit-animation-delay: .52s;
                            animation-delay: .52s;
                     }
                    
                     .loader.circle-line span:nth-child(5) {
                            left: 3.5rem;
                            top: 50%;
                            margin-top: -.25rem;
                            -webkit-transform: rotate(180deg);
                            transform: rotate(180deg);
                            -webkit-animation-delay: .65s;
                            animation-delay: .65s;
                     }
                    
                     .loader.circle-line span:nth-child(6) {
                            bottom: 1rem;
                            right: .5rem;
                            -webkit-transform: rotate(-145deg);
                            transform: rotate(-145deg);
                            -webkit-animation-delay: .78s;
                            animation-delay: .78s;
                     }
                    
                     .loader.circle-line span:nth-child(7) {
                            left: 50%;
                            bottom: .5rem;
                            margin-left: -15px;
                            -webkit-transform: rotate(-90deg);
                            transform: rotate(-90deg);
                            -webkit-animation-delay: .91s;
                            animation-delay: .91s;
                     }
                    
                     .loader.circle-line span:nth-child(8) {
                            bottom: 1rem;
                            left: .5rem;
                            -webkit-transform: rotate(-45deg);
                            transform: rotate(-45deg);
                            -webkit-animation-delay: 1.04s;
                            animation-delay: 1.04s;
                     }
                    
                     @keyframes circle-line {
                            0% {
                                   opacity: .05;
                            }
                            100% {
                                   opacity: .7;
                            }
                     }
                    
                     @-webkit-keyframes circle-line {
                            0% {
                                   opacity: .05;
                            }
                            100% {
                                   opacity: .7;
                            }
                     }
                     /*circle-line-spin*/
                    
                     .loader.circle-line-spin .circle-line-inner {
                            width: 100%;
                            height: 100%;
                            -webkit-animation: circle-line-spin 1.5s linear infinite;
                            animation: circle-line-spin 1.5s linear infinite;
                     }
                    
                     .loader.circle-line-spin span {
                            position: absolute;
                            display: inline-block;
                            width: 1.5rem;
                            height: .5rem;
                            border-top-left-radius: .25rem;
                            border-bottom-left-radius: .25rem;
                            background: #1ABC9C;
                            opacity: .7;
                     }
                    
                     .loader.circle-line-spin span:nth-child(1) {
                            top: 50%;
                            left: 0;
                            margin-top: -.25rem;
                     }
                    
                     .loader.circle-line-spin span:nth-child(2) {
                            top: 1rem;
                            left: .5rem;
                            -webkit-transform: rotate(45deg);
                            transform: rotate(45deg);
                     }
                    
                     .loader.circle-line-spin span:nth-child(3) {
                            left: 50%;
                            top: .5rem;
                            margin-left: -.75rem;
                            -webkit-transform: rotate(90deg);
                            transform: rotate(90deg);
                     }
                    
                     .loader.circle-line-spin span:nth-child(4) {
                            right: .5rem;
                            top: 1rem;
                            -webkit-transform: rotate(145deg);
                            transform: rotate(145deg);
                     }
                    
                     .loader.circle-line-spin span:nth-child(5) {
                            left: 3.5rem;
                            top: 50%;
                            margin-top: -.25rem;
                            -webkit-transform: rotate(180deg);
                            transform: rotate(180deg);
                     }
                    
                     .loader.circle-line-spin span:nth-child(6) {
                            bottom: 1rem;
                            right: .5rem;
                            -webkit-transform: rotate(-145deg);
                            transform: rotate(-145deg);
                     }
                    
                     .loader.circle-line-spin span:nth-child(7) {
                            left: 50%;
                            bottom: .5rem;
                            margin-left: -15px;
                            -webkit-transform: rotate(-90deg);
                            transform: rotate(-90deg);
                     }
                    
                     .loader.circle-line-spin span:nth-child(8) {
                            bottom: 1rem;
                            left: .5rem;
                            -webkit-transform: rotate(-45deg);
                            transform: rotate(-45deg);
                     }
                    
                     @keyframes circle-line-spin {
                            0% {
                                   transform: rotate(0);
                            }
                            100% {
                                   transform: rotate(360deg);
                            }
                     }
                    
                     @-webkit-keyframes circle-line-spin {
                            0% {
                                   -webkit-transform: rotate(0);
                            }
                            100% {
                                   -webkit-transform: rotate(360deg);
                            }
                     }
                     /*circle-round*/
                    
                     .loader.circle-round span {
                            opacity: .05;
                            -webkit-animation: circle-round 1s ease infinite;
                            animation: circle-round 1s ease infinite;
                     }
                    
                     .loader.circle-round-fade span {
                            -webkit-animation: circle-round-fade 1s ease infinite;
                            animation: circle-round-fade 1s ease infinite;
                     }
                    
                     .loader.circle-round span,
                     .loader.circle-round-fade span {
                            position: absolute;
                            width: .8rem;
                            height: .8rem;
                            display: inline-block;
                            border-radius: 50%;
                            background: #1ABC9C;
                     }
                    
                     .loader.circle-round span:nth-child(1),
                     .loader.circle-round-fade span:nth-child(1) {
                            top: 50%;
                            left: 0;
                            margin-top: -.4rem;
                            -webkit-animation-delay: -1.04s;
                            animation-delay: -1.04s;
                     }
                    
                     .loader.circle-round span:nth-child(2),
                     .loader.circle-round-fade span:nth-child(2) {
                            top: .7rem;
                            left: .7rem;
                            -webkit-animation-delay: -.91s;
                            animation-delay: -.91s;
                     }
                    
                     .loader.circle-round span:nth-child(3),
                     .loader.circle-round-fade span:nth-child(3) {
                            top: 0;
                            left: 50%;
                            margin-left: -.4rem;
                            -webkit-animation-delay: -.78s;
                            animation-delay: -.78s;
                     }
                    
                     .loader.circle-round span:nth-child(4),
                     .loader.circle-round-fade span:nth-child(4) {
                            right: .7rem;
                            top: .7rem;
                            -webkit-animation-delay: -.65s;
                            animation-delay: -.65s;
                     }
                    
                     .loader.circle-round span:nth-child(5),
                     .loader.circle-round-fade span:nth-child(5) {
                            right: 0;
                            top: 50%;
                            margin-top: -.4rem;
                            -webkit-animation-delay: -.52s;
                            animation-delay: -.52s;
                     }
                    
                     .loader.circle-round span:nth-child(6),
                     .loader.circle-round-fade span:nth-child(6) {
                            bottom: .7rem;
                            right: .7rem;
                            -webkit-animation-delay: -.39s;
                            animation-delay: -.39s;
                     }
                    
                     .loader.circle-round span:nth-child(7),
                     .loader.circle-round-fade span:nth-child(7) {
                            bottom: 0;
                            left: 50%;
                            margin-left: -.4rem;
                            -webkit-animation-delay: -.26s;
                            animation-delay: -.26s;
                     }
                    
                     .loader.circle-round span:nth-child(8),
                     .loader.circle-round-fade span:nth-child(8) {
                            left: .7rem;
                            bottom: .7rem;
                            -webkit-animation-delay: -.13s;
                            animation-delay: -.13s;
                     }
                    
                     @keyframes circle-round {
                            0% {
                                   opacity: .05;
                            }
                            100% {
                                   opacity: .7;
                            }
                     }
                    
                     @-webkit-keyframes circle-round {
                            0% {
                                   opacity: .05;
                            }
                            100% {
                                   opacity: .7;
                            }
                     }
                    
                     @keyframes circle-round-fade {
                            0% {
                                   opacity: .25;
                                   transform: scale(.2);
                            }
                            100% {
                                   opacity: 1;
                                   transform: scale(1);
                            }
                     }
                    
                     @-webkit-keyframes circle-round-fade {
                            0% {
                                   opacity: .25;
                                   transform: scale(.2);
                            }
                            100% {
                                   opacity: 1;
                                   transform: scale(1);
                            }
                     }
                     /*line-square*/
                    
                     .loader.line-square {
                            width: 6rem;
                            height: .8rem;
                     }
                    
                     .loader.line-square span {
                            position: absolute;
                            top: 0;
                            width: .8rem;
                            height: .8rem;
                            display: inline-block;
                            background: #1ABC9C;
                            -webkit-animation: line-square 1s ease infinite;
                            animation: line-square 1s ease infinite;
                     }
                    
                     .loader.line-square span:nth-child(1) {
                            left: 0;
                            -webkit-animation-delay: .13s;
                            animation-delay: .13s;
                     }
                    
                     .loader.line-square span:nth-child(2) {
                            left: 1.3rem;
                            -webkit-animation-delay: .26s;
                            animation-delay: .26s;
                     }
                    
                     .loader.line-square span:nth-child(3) {
                            left: 2.6rem;
                            -webkit-animation-delay: .39s;
                            animation-delay: .39s;
                     }
                    
                     .loader.line-square span:nth-child(4) {
                            left: 3.9rem;
                            -webkit-animation-delay: .52s;
                            animation-delay: .52s;
                     }
                    
                     .loader.line-square span:nth-child(5) {
                            left: 5.2rem;
                            -webkit-animation-delay: .65s;
                            animation-delay: .65s;
                     }
                    
                     @keyframes line-square {
                            0% {
                                   opacity: 1;
                                   transform: scale(1.2);
                                   -webkit-transform: scale(1.2);
                            }
                            100% {
                                   opacity: .2;
                                   transform: scale(.2);
                                   -webkit-transform: scale(.2);
                            }
                     }
                    
                     @-webkit-keyframes line-square {
                            0% {
                                   opacity: 1;
                                   transform: scale(1.2);
                                   -webkit-transform: scale(1.2);
                            }
                            100% {
                                   opacity: .2;
                                   transform: scale(.2);
                                   -webkit-transform: scale(.2);
                            }
                     }
                     /*line-round*/
                    
                     .loader.line-round {
                            width: 6rem;
                            height: .8rem;
                     }
                    
                     .loader.line-round span {
                            position: absolute;
                            top: 0;
                            width: .8rem;
                            height: .8rem;
                            border-radius: 50%;
                            display: inline-block;
                            background: #1ABC9C;
                            -webkit-animation: line-round 1s ease infinite;
                            animation: line-round 1s ease infinite;
                     }
                    
                     .loader.line-round span:nth-child(1) {
                            left: 0;
                            -webkit-animation-delay: .13s;
                            animation-delay: .13s;
                     }
                    
                     .loader.line-round span:nth-child(2) {
                            left: 1.3rem;
                            -webkit-animation-delay: .26s;
                            animation-delay: .26s;
                     }
                    
                     .loader.line-round span:nth-child(3) {
                            left: 2.6rem;
                            -webkit-animation-delay: .39s;
                            animation-delay: .39s;
                     }
                    
                     .loader.line-round span:nth-child(4) {
                            left: 3.9rem;
                            -webkit-animation-delay: .52s;
                            animation-delay: .52s;
                     }
                    
                     .loader.line-round span:nth-child(5) {
                            left: 5.2rem;
                            -webkit-animation-delay: .65s;
                            animation-delay: .65s;
                     }
                    
                     @keyframes line-round {
                            0% {
                                   opacity: 1;
                                   transform: scale(1.2);
                                   -webkit-transform: scale(1.2);
                            }
                            100% {
                                   opacity: .2;
                                   transform: scale(.2);
                                   -webkit-transform: scale(.2);
                            }
                     }
                    
                     @-webkit-keyframes line-round {
                            0% {
                                   opacity: 1;
                                   transform: scale(1.2);
                                   -webkit-transform: scale(1.2);
                            }
                            100% {
                                   opacity: .2;
                                   transform: scale(.2);
                                   -webkit-transform: scale(.2);
                            }
                     }
                     /*line-bounce*/
                    
                     .loader.line-bounce {
                            width: 6rem;
                            height: 2.5rem;
                     }
                    
                     .loader.line-bounce span {
                            position: absolute;
                            top: 0;
                            width: .5rem;
                            height: 2.5rem;
                            border-radius: 5px;
                            display: inline-block;
                            background: #1ABC9C;
                            -webkit-animation: line-bounce 1s ease infinite;
                            animation: line-bounce 1s ease infinite;
                     }
                    
                     .loader.line-bounce span:nth-child(1) {
                            left: 0;
                            -webkit-animation-delay: -.65s;
                            animation-delay: -.65s;
                     }
                    
                     .loader.line-bounce span:nth-child(2) {
                            left: 1.3rem;
                            -webkit-animation-delay: -.78s;
                            animation-delay: -.78s;
                     }
                    
                     .loader.line-bounce span:nth-child(3) {
                            left: 2.6rem;
                            -webkit-animation-delay: -.91s;
                            animation-delay: -.91s;
                     }
                    
                     .loader.line-bounce span:nth-child(4) {
                            left: 3.9rem;
                            -webkit-animation-delay: -.78s;
                            animation-delay: -78s;
                     }
                    
                     .loader.line-bounce span:nth-child(5) {
                            left: 5.2rem;
                            -webkit-animation-delay: -.65s;
                            animation-delay: -.65s;
                     }
                    
                     @keyframes line-bounce {
                            0% {
                                   transform: scaleY(1);
                            }
                            50% {
                                   transform: scaleY(.3);
                            }
                            100% {
                                   transform: scaleY(1);
                            }
                     }
                    
                     @-webkit-keyframes line-bounce {
                            0% {
                                   -webkit-transform: scaleY(1);
                            }
                            50% {
                                   -webkit-transform: scaleY(.3);
                            }
                            100% {
                                   -webkit-transform: scaleY(1);
                            }
                     }
                     /*circle-spin*/
                    
                     .loader.circle-spin {
                            border-radius: 50%;
                            border: .2rem solid rgba(0, 0, 0, .05);
                            width: 4rem;
                            height: 4rem;
                            box-sizing: content-box;
                     }
                    
                     .loader.circle-spin .loader-placeholder {
                            position: absolute;
                            top: -.2rem;
                            left: -.2rem;
                            border-radius: 50%;
                            border: .2rem solid transparent;
                            border-top: .2rem solid #1ABC9C;
                            width: 4rem;
                            height: 4rem;
                            box-sizing: content-box;
                            -webkit-animation: circle-spin 1s ease infinite;
                            animation: circle-spin 1s ease infinite;
                     }
                    
                     @keyframes circle-spin {
                            0% {
                                   transform: rotate(0);
                            }
                            100% {
                                   transform: rotate(360deg);
                            }
                     }
                    
                     @-webkit-keyframes circle-spin {
                            0% {
                                   -webkit-transform: rotate(0);
                            }
                            100% {
                                   -webkit-transform: rotate(360deg);
                            }
                     }
              </style>
       </head>
 
       <body>
              <div>
                     <div class="loader circle-line small">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                     </div>
                     <div class="loader circle-line-spin small">
                            <div>
                                   <span></span>
                                   <span></span>
                                   <span></span>
                                   <span></span>
                                   <span></span>
                                   <span></span>
                                   <span></span>
                                   <span></span>
                            </div>
                     </div>
                     <div class="loader circle-round small">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                     </div>
                     <div class="loader circle-round-fade small">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                     </div>
                     <div class="loader line-square small">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                     </div>
                     <div class="loader line-round small">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                     </div>
                     <div class="loader line-bounce small">
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                            <span></span>
                     </div>
                     <div class="loader circle-spin small">
                            <div></div>
                     </div>
              </div>
 
       </body>
</html>


I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

HTML5 responsive banner production tutorial

Using H5 to create water droplet special effects tutorial

Steps to implement HTML webpage optimization and compression

The above is the detailed content of Implementation of several common loding effects. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Iterating a React Design with Styled ComponentsIterating a React Design with Styled ComponentsApr 21, 2025 am 11:29 AM

In a perfect world, our projects would have unlimited resources and time. Our teams would begin coding with well thought out and highly refined UX designs.

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons!Oh, the Many Ways to Make Triangular Breadcrumb Ribbons!Apr 21, 2025 am 11:26 AM

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons

SVG Properties in CSS GuideSVG Properties in CSS GuideApr 21, 2025 am 11:21 AM

SVG has its own set of elements, attributes and properties to the extent that inline SVG code can get long and complex. By leveraging CSS and some of the forthcoming features of the SVG 2 specification, we can reduce that code for cleaner markup.

A Few Functional Uses for Intersection Observer to Know When an Element is in ViewA Few Functional Uses for Intersection Observer to Know When an Element is in ViewApr 21, 2025 am 11:19 AM

You might not know this, but JavaScript has stealthily accumulated quite a number of observers in recent times, and Intersection Observer is a part of that

Revisting prefers-reduced-motionRevisting prefers-reduced-motionApr 21, 2025 am 11:18 AM

We may not need to throw out all CSS animations. Remember, it’s prefers-reduced-motion, not prefers-no-motion.

How to Get a Progressive Web App into the Google Play StoreHow to Get a Progressive Web App into the Google Play StoreApr 21, 2025 am 11:10 AM

PWA (Progressive Web Apps) have been with us for some time now. Yet, each time I try explaining it to clients, the same question pops up: "Will my users be

The Simplest Ways to Handle HTML IncludesThe Simplest Ways to Handle HTML IncludesApr 21, 2025 am 11:09 AM

It's extremely surprising to me that HTML has never had any way to include other HTML files within it. Nor does there seem to be anything on the horizon that

Change Color of SVG on HoverChange Color of SVG on HoverApr 21, 2025 am 11:04 AM

There are a lot of different ways to use SVG. Depending on which way, the tactic for recoloring that SVG in different states or conditions — :hover,

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools