1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Loading Animation</title>
7 <style>
8 body {
9 background-color: #000;
10 display: flex;
11 justify-content: center;
12 align-items: center;
13 height: 100vh;
14 margin: 0;
15 }
16 .loading-bar {
17 position: relative;
18 width: 100px;
19 height: 20px;
20 background-color: #333;
21 overflow: hidden;
22 }
23 .loading-bar::before {
24 content: "";
25 position: absolute;
26 top: 0;
27 left: 0;
28 width: 0;
29 height: 100%;
30 background: linear-gradient(to right, #ff0000, #0000ff);
31 }
32 @keyframes load {
33 0% {
34 width: 0;
35 }
36 100% {
37 width: 100%;
38 }
39 }
40 </style>
41</head>
42<body>
43 <div class="loading-bar" id="loadingBar"></div>
44 <script>
45 const loadingBar = document.getElementById('loadingBar');
46 let width = 0;
47 const interval = setInterval(() => {
48 width += 1;
49 loadingBar.style.setProperty('--width', `${width}%`);
50 if (width >= 100) {
51 clearInterval(interval);
52 }
53 }, 20);
54 loadingBar.style.setProperty('--width', '0%');
55 </script>
56</body>
57</html>