Skip to content

Commit fefb2e1

Browse files
committed
added css variables exercise
1 parent 1ed98dc commit fefb2e1

File tree

2 files changed

+26
-74
lines changed

2 files changed

+26
-74
lines changed

03 - CSS Variables/index-START.html

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,28 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
1414
<label for="blur">Blur:</label>
1515
<input type="range" name="blur" min="0" max="25" value="10" data-sizing="px">
1616

17+
<label for="pfont-size">Font Size:</label>
18+
<input type="range" name="font-size" min="0" max="525" value="10" data-sizing="px">
19+
1720
<label for="base">Base Color</label>
1821
<input type="color" name="base" value="#ffc600">
1922
</div>
2023

21-
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
24+
<!--<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">-->
25+
<h1 class="penis">penis</h1>
2226

2327
<style>
28+
2429
:root {
2530
--base: #ffc600;
26-
--spacing: 10px;
31+
--spacing: 50px;
2732
--blur: 10px;
33+
--font-size: 10px;
2834
}
2935

30-
img {
36+
img {
3137
padding: var(--spacing);
32-
background: var(--base);
33-
filter: blur(var(--blur));
34-
}
35-
36-
.hl {
37-
color: var(--base);
38-
}
39-
38+
}
4039
/*
4140
misc styles, nothing to do with CSS variables
4241
*/
@@ -52,6 +51,19 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
5251
font-weight: 100;
5352
font-size: 50px;
5453
}
54+
.penis {
55+
font-family: 'comic-sans';
56+
font-size: var(--font-size);
57+
color: var(--base);
58+
filter: blur(var(--blur));
59+
letter-spacing: var(--spacing);
60+
}
61+
.hl {
62+
font-size: var(--font-size);
63+
color: var(--base);
64+
filter: blur(var(--blur));
65+
letter-spacing: var(--spacing);
66+
}
5567

5668
.controls {
5769
margin-bottom: 50px;
@@ -70,15 +82,14 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
7082
<script>
7183
const inputs = document.querySelectorAll('.controls input');
7284

73-
function handleUpdate() {
85+
function handleUpdate(){
7486
const suffix = this.dataset.sizing || '';
75-
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
87+
document.documentElement.style.setProperty(`--${this.name}`, `${this.value}${suffix}`);
88+
console.log(this.name);
7689
}
77-
7890
inputs.forEach(input => input.addEventListener('change', handleUpdate));
7991
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
8092
</script>
8193

82-
8394
</body>
8495
</html>

0 commit comments

Comments
 (0)