Skip to content

Commit 454e333

Browse files
committed
day 3 solved
1 parent 69cdfd9 commit 454e333

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

03 - CSS Variables/index-START.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2222

2323
<style>
2424

25-
/*
26-
misc styles, nothing to do with CSS variables
27-
*/
25+
:root {
26+
--base: #ffc600;
27+
--spacing: 10px;
28+
--blur: 10px;
29+
}
30+
31+
img {
32+
padding: var(--spacing);
33+
background: var(--base);
34+
filter: blur(var(--blur));
35+
}
2836

2937
body {
3038
text-align: center;
@@ -53,6 +61,14 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
5361
</style>
5462

5563
<script>
64+
const controls = document.querySelectorAll('.controls input');
65+
66+
const handleUpdate = (e) => {
67+
const suffix = e.target.dataset.sizing || '';
68+
document.documentElement.style.setProperty(`--${e.target.name}`, e.target.value + suffix);
69+
}
70+
controls.forEach(control => control.addEventListener('change', handleUpdate));
71+
// controls.forEach(control => control.addEventListener('mousemove', handleUpdate));
5672
</script>
5773

5874
</body>

0 commit comments

Comments
 (0)