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)
The problem that MYSQL5.7.17 cannot connect under...
1. VMware download and install Link: https://www....
Overview Prometheus is an open source service mon...
1. Document flow and floating 1. What is document...
Code <div class="test"> <div&g...
The configuration method of MySQL 5.5.56 free ins...
1. The role of index Generally speaking, an index...
Table of contents Preface Modifiers of v-model: l...
1. Dynamic parameters Starting from 2.6.0, you ca...
<br />In one year of blogging, I have person...
Table of contents Overview Solution 1: Closures S...
In the fifth issue of Web Skills, a technical sol...
Overview When a 500 or 502 error occurs during ac...
Preface: I received crazy slow query and request ...
1. Introduction MySQL Group Replication (MGR for ...