-
Notifications
You must be signed in to change notification settings - Fork 0
/
cssvar.html
109 lines (92 loc) · 2.8 KB
/
cssvar.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
<!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>Css var with Js</title>
<style>
:root{
--spacing:10px;
--blur:10px;
--base:#ffc600;
}
body{
padding: 20px;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
font-family: monospace;
}
.control{
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 30px;
margin-bottom: 30px;
/* flex-direction: column; */
}
*{
text-align: center;
}
.don{
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
img{
max-width: 70%;
padding: var(--spacing);
background-color: var(--base);
filter: blur(var(--blur));
}
p{
text-align: center;
}
span{
color: var(--base);
}
.name{
background-color: var(--base);
color: black;
padding: 4px;
}
</style>
</head>
<body>
<h1><span>Up</span>date CS<span>S Vari</span>ables w<span>i</span>th <span>J</span>ava<span>S</span>cript</h1>
<div class="control">
<div class="don">
<label for="spacing">Spacing</label>
<input type="range" min="0" max="25" value="5" data-sizing="px" name="spacing">
</div>
<div class="don">
<label for="blur">Blur</label>
<input type="range" min="0" max="10" value="0" data-sizing="px" name="blur">
</div>
<div class="don">
<label for="base">Base Color</label>
<input type="color" value="#ffc600" name="base">
</div>
</div>
<img src="./cssvar/ccsjs.jpg" alt="Yevhenii Ometsynskyi">
<p>Made By <span class="name">Aadil Mugal</span></p>
<script>
let inputs = document.querySelectorAll("input");
function handler(){
let suffix = this.dataset.sizing || "";
// console.log(suffix);
document.documentElement.style.setProperty(`--${this.name}`,`${this.value}`+suffix);
// if(this.name == "spacing")
// if(this.name == "blur")
// if(this.name == "base")
}
inputs.forEach(input => input.addEventListener("change",handler));
// inputs.forEach(input => input.addEventListener("mousemove",handler));
</script>
</body>
</html>