Preview knowledge points.
Start:Create the HTML structure:<section> <div class="loading"> <div class="text"></div> <div class="clock" style="--i:1;"></div> <div class="clock" style="--i:2;"></div> <div class="clock" style="--i:3;"></div> <div class="clock" style="--i:4;"></div> <div class="clock" style="--i:5;"></div> <div class="clock" style="--i:6;"></div> <div class="clock" style="--i:7;"></div> <div class="clock" style="--i:8;"></div> <div class="clock" style="--i:9;"></div> <div class="clock" style="--i:10;"></div> <div class="clock" style="--i:11;"></div> <div class="clock" style="--i:12;"></div> <div class="clock" style="--i:13;"></div> <div class="clock" style="--i:14;"></div> <div class="clock" style="--i:15;"></div> <div class="clock" style="--i:16;"></div> <div class="clock" style="--i:17;"></div> <div class="clock" style="--i:18;"></div> <div class="clock" style="--i:19;"></div> <div class="clock" style="--i:20;"></div> </div> </section>
Center the box:*{ margin: 0; padding: 0; box-sizing: border-box; } section{ display:flex; justify-content: center; align-items: center; min-height: 100vh; background: -webkit-linear-gradient(left top, pink, orange); }
Set the loading box size..loading{ position: relative; width: 250px; height: 250px; } Position the text and circle box inside the loading box..loading .text::after{ content: "Loading"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #000; font-size: 24px; font-weight:600; height: 66px; width: 130px; text-align: center; line-height: 66px; transition: all .5s; letter-spacing: 2px; } .loading .clock{ position:absolute; left: 50%; height: 25px; width: 8px; background-color:red; transform: rotate(calc(18deg * var(--i))); transform-origin: 0 125px; animation: clock 1.2s linear infinite; animation-delay: calc(0.06s * var(--i)); }
This is how the rotation positioning of the circle box is achieved. Define animation, add animation@keyframes clock { 0%, 50%{ background-color:pink; box-shadow: none; } 50.1%, 100%{ background-color: red; box-shadow: 0 0 5px red, 0 0 10px red, 0 0 25px red, 0 0 40px red; } } transform-origin: 0 125px; animation: clock 1.2s linear infinite; animation-delay: calc(0.06s * var(--i));
Add Hover event to stop animationloading .text:hover::after{ content: "Ended"; transform: translate(-50%, -50%) translateY(-8px) scale(1.3); color: red; } .loading:hover .clock{ animation-play-state: paused; } This is the end of this article about how to use CSS3's var() and calc() functions to achieve animation effects. For more relevant CSS animation effects content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Detailed explanation of where Docker saves log files
>>: Front-end AI cutting tips (experience)
This tutorial shares the specific code of MySQL5....
Preface In actual development, business requireme...
1. The difference between Http and Https HTTP: It...
Table of contents The role of cloneElement Usage ...
Types of Indexes in MySQL Generally, they can be ...
It has always been very difficult to achieve wave...
Float is often used in web page layout, but the f...
Solution: Bind the click event to the audio compo...
In development projects, we can monitor SQL with ...
Environment configuration 1: Install MySQL and ad...
In the previous article, it was mentioned that th...
Table of contents Overview 1. Test for null value...
Table of contents Overview first step Step 2 Why ...
Preface Recently I encountered a requirement, whi...
Table of contents Preface Discover the cause Cust...