File tree Expand file tree Collapse file tree 3 files changed +33
-81
lines changed
Expand file tree Collapse file tree 3 files changed +33
-81
lines changed Original file line number Diff line number Diff line change 1+ // this is selecting all the input elements and controls atributes in the HTML document
2+ const inputs = document . querySelectorAll ( '.controls input' ) ;
3+
4+ function handleUpdate ( ) {
5+ //
6+ const suffix = this . dataset . sizing || '' ;
7+
8+ document . documentElement . style . setProperty ( `--${ this . name } ` , this . value + suffix ) ;
9+ console . log ( suffix ) ;
10+ }
11+
12+ // this updates the inputs
13+ inputs . forEach ( input => input . addEventListener ( 'change' , handleUpdate ) ) ;
14+ // this updates the inputs as the mouse moves
15+ inputs . forEach ( input => input . addEventListener ( 'mousemove' , handleUpdate ) ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -22,6 +22,23 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2222
2323 < style >
2424
25+ /* This is for creating a CSS variable*/
26+ : root {
27+ --base : # ffc600 ;
28+ --spacing : 10px ;
29+ --blur : 10px ;
30+ }
31+
32+ img {
33+ padding : var (--spacing );
34+ background : var (--base );
35+ filter : blur (var (--blur ));
36+ }
37+
38+ .hl {
39+ color : var (--base );
40+ }
41+
2542 /*
2643 misc styles, nothing to do with CSS variables
2744 */
@@ -47,8 +64,7 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
4764 }
4865 </ style >
4966
50- < script >
51- </ script >
67+ < script src ="cssVariables.js "> </ script >
5268
5369</ body >
5470</ html >
You can’t perform that action at this time.
0 commit comments