Skip to content

Commit 6003c9b

Browse files
committed
Day wesbos#3 CSS Variables
1 parent 674ece4 commit 6003c9b

File tree

2 files changed

+14
-61
lines changed

2 files changed

+14
-61
lines changed

03 - CSS Variables/index-START.html

Lines changed: 0 additions & 51 deletions
This file was deleted.

03 - CSS Variables/index-FINISHED.html renamed to 03 - CSS Variables/index.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>Scoped CSS Variables and JS</title>
67
</head>
8+
79
<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>
913

1014
<div class="controls">
1115
<label for="spacing">Spacing:</label>
@@ -21,6 +25,10 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2125
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
2226

2327
<style>
28+
/*
29+
misc styles, nothing to do with CSS variables
30+
*/
31+
2432
:root {
2533
--base: #ffc600;
2634
--spacing: 10px;
@@ -33,14 +41,10 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
3341
filter: blur(var(--blur));
3442
}
3543

36-
.hl {
44+
span.hl {
3745
color: var(--base);
3846
}
3947

40-
/*
41-
misc styles, nothing to do with CSS variables
42-
*/
43-
4448
body {
4549
text-align: center;
4650
background: #193549;
@@ -55,22 +59,22 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
5559
}
5660

5761
input {
58-
width:100px;
62+
width: 100px;
5963
}
6064
</style>
6165

6266
<script>
6367
const inputs = document.querySelectorAll('.controls input');
64-
6568
function handleUpdate() {
6669
const suffix = this.dataset.sizing || '';
6770
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
71+
console.log();
6872
}
6973

7074
inputs.forEach(input => input.addEventListener('change', handleUpdate));
7175
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
7276
</script>
7377

74-
7578
</body>
76-
</html>
79+
80+
</html>

0 commit comments

Comments
 (0)