-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
167 lines (150 loc) · 4.89 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiple Gradient</title>
<style>
.box {
position: relative;
width: 100vw;
height: 100vh;
filter: blur(50vh);
}
.box>div {
position: absolute;
height: 40vh;
width: 40vw;
}
.box2>div {
position: absolute;
right: 0;
height: 30vh;
width: 30vw;
}
@keyframes rolling {
0% {
transform: rotate(0deg);
transform-origin: 0% 0%;
}
100% {
transform: rotate(360deg);
transform-origin: 0% 0%;
}
}
.red {
background-color: red;
animation: rolling 3s linear 0s infinite;
}
.blue {
background-color: blue;
animation: rolling 3s linear 1s infinite;
}
.yellow {
background-color: yellow;
animation: rolling 3s linear 2s infinite;
}
body {
background: radial-gradient(transparent, #000 20px);
background-size: 4px 4px;
overflow: hidden;
transition: all 1s;
height: 100vh;
width: 100vw;
box-sizing: border-box;
}
.switch {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 40px;
width: 80px;
background-image: linear-gradient(to right, #fff, #000);
display: flex;
justify-content: center;
align-items: center;
border: 1px solid #000;
border-radius: 50vmin;
transition: all 1s;
}
.switch>div {
position: absolute;
background-color: transparent;
height: 30px;
width: 30px;
border-radius: 50%;
transform: translateX(-50%);
cursor: pointer;
animation: triger 0.5s ease-in-out 0s forwards;
animation-play-state: paused;
box-shadow: 0 0 0 1px #000;
}
.reverse-animation {
animation-direction: reverse;
}
@keyframes triger {
0% {
transform: translateX(-50%);
background-color: #fff;
}
100% {
transform: translateX(50%);
background-color: #000;
}
}
@media screen and (max-width: 1000px) {
.switch {
top: 0;
left: 100%;
transform: translate(-100%, 10%);
}
}
</style>
</head>
<body>
<div style="position: absolute;">
<div class="box">
<div class="red"></div>
<div class="blue"></div>
<div class="yellow"></div>
</div>
<div class="box2 box">
<div class="red"></div>
<div class="blue"></div>
<div class="yellow"></div>
</div>
</div>
<div class="switch" style="z-index: 9;">
<div> </div>
</div>
<script>
(() => {
let f = { value: 1 };
f = new Proxy(f, {
set: function (target, key, value) {
if (value == 1) {
document.querySelector("body").style.backgroundImage = "radial-gradient(transparent, #000 20px)";
document.querySelector("body").style.backgroundColor = "#fff"
} else {
document.querySelector("body").style.backgroundImage = "radial-gradient(transparent, #fff 20px)";
document.querySelector("body").style.backgroundColor = "#000"
}
console.log(document.querySelector("body").style)
target[key] = value;
return true;
}
});
document.querySelector(".switch>div").addEventListener("click", function () {
var switchDiv = document.querySelector(".switch>div");
switchDiv.style.animation = 'null'
void switchDiv.offsetWidth;
switchDiv.style.animation = f.value == 1 ? 'triger 0.5s ease-in-out 0s forwards' : 'triger 0.5s ease-in-out 0s reverse forwards'
f.value = f.value == 1 ? 2 : 1;
switchDiv.style.animationPlayState = "running";
})
})()
</script>
</body>
</html>