-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
92 lines (61 loc) · 1.92 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
:root {
--base: #ffc600;
--spacing: 10px;
--blur: 10px;
}
body {
text-align: center;
background: #193549;
color: white;
font-family: "helvetica neue", sans-serif;
font-weight: 100;
font-size: 50px;
}
img {
padding: var(--spacing);
background: var(--base);
filter: blur(var(--blur));
height: 70vh;
width: 50%;
}
.h2 {
color: var(--base);
}
.controls {
margin-bottom: 50px;
}
input {
width: 100px;
}
</style>
</head>
<body>
<h2>Update css variables with JS</h2>
<div class="controls">
<label for="spacing">Spacing:</label>
<input type="range" id="spacing" name="spacing" min="10" max="200" value="10" data-sizing="px">
<label for="blur">Blur:</label>
<input type="range" id="blur" name="blur" min="0" max="25" value="10" data-sizing="px">
<label for="base">Base Color</label>
<input type="color" name="base" id="base" value="#ffc600">
</div>
<img src="pic1.jpeg" alt="">
<script>
var inputs = document.querySelectorAll(".controls input");
function setproperty() {
var suffix = this.dataset.sizing || "";
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
}
inputs.forEach(input => input.addEventListener("change", setproperty));
inputs.forEach(input => input.addEventListener("mousemove", setproperty));
</script>
</body>
</html>