-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.html
61 lines (57 loc) · 1.74 KB
/
background.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Tiled Background with Individual Rotation</title>
<style>
body, html {
height: 100%;
margin: 0;
overflow: hidden;
}
.background {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: repeat(9, 1fr);
grid-template-rows: repeat(5, 1fr);
}
.tile {
background-image: url('app/assets/images/Bike_icon.png');
background-size: 100%;
animation: rotate 0.7s linear infinite;
margin: 20px;
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="background" id="background"></div>
<script>
const background = document.getElementById('background');
const totalTiles = 27;
for (let i = 0; i < totalTiles; i++) {
const tile = document.createElement('div');
tile.className = 'tile';
background.appendChild(tile);
}
const tiles = document.querySelectorAll('.tile');
let rotating = true;
function toggleRotation() {
tiles.forEach(tile => {
if (rotating) {
tile.style.animationPlayState = 'paused';
} else {
tile.style.animationPlayState = 'running';
}
});
rotating = !rotating;
}
setInterval(toggleRotation, 500); // Toggle every 10 seconds
</script>
</body>
</html>