-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add demo header & add 10_Hold-Shift-and-Check-Checkboxes
- Loading branch information
Showing
16 changed files
with
1,197 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.DS_Store | ||
.DS_Store | ||
_* | ||
.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,107 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Scoped CSS Variables and JS</title> | ||
<script src="ga.js"></script> | ||
<meta charset="UTF-8"> | ||
<title>Scoped CSS Variables and JS</title> | ||
<script src="ga.js"></script> | ||
</head> | ||
<body> | ||
<h2>Update CSS Variables with <span class='hl'>JS</span></h2> | ||
|
||
<div class="controls"> | ||
<label for="spacing">Spacing:</label> | ||
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px"> | ||
|
||
<label for="blur">Blur:</label> | ||
<input id="blur" type="range" name="blur" min="0" max="25" value="0" data-sizing="px"> | ||
|
||
<label for="grayscale">grayscale:</label> | ||
<input id="grayscale" type="range" name="grayscale" min="0" max="100" value="0" data-sizing="%"> | ||
|
||
<label for="base">Base Color</label> | ||
<input id="base" type="color" name="base" value="#ffc600"> | ||
</div> | ||
|
||
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500"> | ||
|
||
<style> | ||
:root { | ||
--base: #ffc600; | ||
--spacing: 10px; | ||
--blur: 10px; | ||
--grayscale: 0%; | ||
} | ||
|
||
img { | ||
padding: var(--spacing); | ||
background: var(--base); | ||
filter: blur(var(--blur)) grayscale(var(--grayscale)); | ||
} | ||
|
||
.hl { | ||
color: var(--base); | ||
} | ||
|
||
/* | ||
misc styles, nothing to do with CSS variables | ||
*/ | ||
|
||
body { | ||
text-align: center; | ||
background: #193549; | ||
color: white; | ||
font-family: 'helvetica neue', sans-serif; | ||
font-weight: 100; | ||
font-size: 50px; | ||
} | ||
|
||
.controls { | ||
margin-bottom: 50px; | ||
} | ||
|
||
input { | ||
width:100px; | ||
} | ||
</style> | ||
|
||
<script> | ||
const inputs = document.querySelectorAll('.controls input'); | ||
|
||
function handleUpdate() { | ||
const suffix = this.dataset.sizing || ''; | ||
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix); | ||
} | ||
|
||
inputs.forEach(input => input.addEventListener('change', handleUpdate)); | ||
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate)); | ||
</script> | ||
<body> | ||
<style> | ||
.GuaHsu-header { | ||
background-color: #333; | ||
text-align: center; | ||
padding: 10px; | ||
color: #7ff3cb; | ||
font-size: 20px; | ||
font-weight: 100; | ||
} | ||
|
||
.GuaHsu-header span { | ||
margin: 0 5px; | ||
} | ||
|
||
.GuaHsu-header a { | ||
text-decoration: none; | ||
color: unset; | ||
} | ||
</style> | ||
<div class="GuaHsu-header"> | ||
<span><a href="https://guahsu.io/categories/JavaScript30/" target="_blank">JavaScript30 心得</a></span> | ||
<span>|</span> | ||
<span><a href="https://github.com/guahsu/JavaScript30" target="_blank">GitHub</a></span> | ||
</div> | ||
<h2>Update CSS Variables with <span class='hl'>JS</span></h2> | ||
|
||
<div class="controls"> | ||
<label for="spacing">Spacing:</label> | ||
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px"> | ||
|
||
<label for="blur">Blur:</label> | ||
<input id="blur" type="range" name="blur" min="0" max="25" value="0" data-sizing="px"> | ||
|
||
<label for="grayscale">grayscale:</label> | ||
<input id="grayscale" type="range" name="grayscale" min="0" max="100" value="0" data-sizing="%"> | ||
|
||
<label for="base">Base Color</label> | ||
<input id="base" type="color" name="base" value="#ffc600"> | ||
</div> | ||
|
||
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500"> | ||
|
||
<style> | ||
:root { | ||
--base: #ffc600; | ||
--spacing: 10px; | ||
--blur: 10px; | ||
--grayscale: 0%; | ||
} | ||
|
||
img { | ||
padding: var(--spacing); | ||
background: var(--base); | ||
filter: blur(var(--blur)) grayscale(var(--grayscale)); | ||
} | ||
|
||
.hl { | ||
color: var(--base); | ||
} | ||
/* | ||
misc styles, nothing to do with CSS variables | ||
*/ | ||
|
||
body { | ||
text-align: center; | ||
background: #193549; | ||
color: white; | ||
font-family: 'helvetica neue', sans-serif; | ||
font-weight: 100; | ||
font-size: 50px; | ||
} | ||
|
||
.controls { | ||
margin-bottom: 50px; | ||
} | ||
|
||
input { | ||
width: 100px; | ||
} | ||
</style> | ||
|
||
<script> | ||
const inputs = document.querySelectorAll('.controls input'); | ||
|
||
function handleUpdate() { | ||
const suffix = this.dataset.sizing || ''; | ||
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix); | ||
} | ||
|
||
inputs.forEach(input => input.addEventListener('change', handleUpdate)); | ||
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate)); | ||
</script> | ||
|
||
|
||
</body> | ||
</html> | ||
|
||
</html> |
Oops, something went wrong.