File tree Expand file tree Collapse file tree 2 files changed +14
-61
lines changed Expand file tree Collapse file tree 2 files changed +14
-61
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
+
3
4
< head >
4
5
< meta charset ="UTF-8 ">
5
6
< title > Scoped CSS Variables and JS</ title >
6
7
</ head >
8
+
7
9
< body >
8
- < h2 > Update CSS Variables with < span class ='hl '> JS</ span > </ h2 >
10
+ < h2 > Update CSS Variables with
11
+ < span class ='hl '> JS</ span >
12
+ </ h2 >
9
13
10
14
< div class ="controls ">
11
15
< label for ="spacing "> Spacing:</ label >
@@ -21,6 +25,10 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
21
25
< img src ="https://source.unsplash.com/7bwQXzbF6KE/800x500 ">
22
26
23
27
< style >
28
+ /*
29
+ misc styles, nothing to do with CSS variables
30
+ */
31
+
24
32
: root {
25
33
--base : # ffc600 ;
26
34
--spacing : 10px ;
@@ -33,14 +41,10 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
33
41
filter : blur (var (--blur ));
34
42
}
35
43
36
- .hl {
44
+ span .hl {
37
45
color : var (--base );
38
46
}
39
47
40
- /*
41
- misc styles, nothing to do with CSS variables
42
- */
43
-
44
48
body {
45
49
text-align : center;
46
50
background : # 193549 ;
@@ -55,22 +59,22 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
55
59
}
56
60
57
61
input {
58
- width : 100px ;
62
+ width : 100px ;
59
63
}
60
64
</ style >
61
65
62
66
< script >
63
67
const inputs = document . querySelectorAll ( '.controls input' ) ;
64
-
65
68
function handleUpdate ( ) {
66
69
const suffix = this . dataset . sizing || '' ;
67
70
document . documentElement . style . setProperty ( `--${ this . name } ` , this . value + suffix ) ;
71
+ console . log ( ) ;
68
72
}
69
73
70
74
inputs . forEach ( input => input . addEventListener ( 'change' , handleUpdate ) ) ;
71
75
inputs . forEach ( input => input . addEventListener ( 'mousemove' , handleUpdate ) ) ;
72
76
</ script >
73
77
74
-
75
78
</ body >
76
- </ html >
79
+
80
+ </ html >
You can’t perform that action at this time.
0 commit comments