03 - CSS Variables
How do I make an 03 - css variables?
03 - CSS VariablesBuild 30 things in 30 days using Vanilla JShttps://javascript30.com. What is a 03 - css variables? How do you make a 03 - css variables? This script and codes were developed by Dave Alger on 11 August 2022, Thursday.
03 - CSS Variables - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>03 - CSS Variables</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="page">
<div class="left-side">
<h2>Update CSS Variables with <span class='hl'>JS</span></h2>
<div class="controls"> <label for="spacing">Spacing</label> <input type="range" name="spacing" min="0" max="10" value="5" data-sizing="vh"> <br/><br/> <label for="blur">Blur</label> <input type="range" name="blur" min="0" max="10" value="5" data-sizing="vh"> <br/><br/> <label for="base" class="shift">Color</label> <input type="color" name="base" value="#368DDA" class="shift">
</div>
</div>
<div class="right-side">
<img src="https://raw.githubusercontent.com/run-time/JavaScript30/7139f9058c0a6123491449a27c4f93e4948f33a2/03%20-%20CSS%20Variables/waldo.png" />
</div>
</div> <script src="js/index.js"></script>
</body>
</html>
03 - CSS Variables - Script Codes CSS Codes
:root { --iammenasco_blue: #368DDA; --dave_alger_gray: #DADADA; --base: #368DDA; --spacing: 5vh; --blur: 5vh;
}
body { margin: 0; padding: 0; min-height: 100vh; background-color: #1d1f20; background-image: radial-gradient( circle at top center, #2d2f30, #1d1f20 ); text-align: center; font-family: sans-serif; color: #fff;
}
h2 { color: var(--dave_alger_gray); font-size: 28px; font-weight: normal; margin: 0 0 12px 0;
}
.controls { display: inline-block; text-align: right; margin: 0 0 20px 0; padding: 10px;
}
label { padding: 0 20px; line-height: 24px; font-size: 18px; display: inline-block; text-align: right; position: relative; top: -5px;
}
img { width: 45vh; height: 70vh; min-width: 140px; min-height: 210px; padding: var(--spacing); background: var(--base); filter: blur(var(--blur));
}
.hl { color: var(--base);
}
input { width: 140px;
}
.shift { position: relative;
}
label.shift { top: 0; left: -6px;
}
input.shift { width: 134px; left: -6px;
}
.left-side,
.right-side { display: inline-block; padding: 20px; vertical-align: top;
}
.left-side { text-align: right;
}
.right-side { text-align: left; cursor: pointer;
}
.page { vertical-align: top; padding-top: 4vh;
}
03 - CSS Variables - Script Codes JS Codes
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('input', handleUpdate));
const waldo = document.querySelector('.right-side');
waldo.addEventListener('click', resetValues);
function resetValues() { inputs.forEach(input => { console.log(input.type); if (input.type === 'range') { input.value = 0; document.documentElement.style.setProperty(`--${input.name}`, '0'); } else { input.value = '#368DDA'; document.documentElement.style.setProperty(`--${input.name}`, '#368DDA'); } });
}
Developer | Dave Alger |
Username | run-time |
Uploaded | August 11, 2022 |
Rating | 4 |
Size | 2,682 Kb |
Views | 34,408 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Phone Input Field | 2,255 Kb |
Color Picker | 3,410 Kb |
The Ultimate Canvas Compression | 6,183 Kb |
Editable Fire Text | 3,997 Kb |
Fireflies | 2,940 Kb |
JavaScript Fingerprint | 13,935 Kb |
JavaScript water droplet effect | 3,189 Kb |
Download Speed Calculator | 3,412 Kb |
Basic FAQ | 2,365 Kb |
Slow Motion Shatter | 3,326 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Donut Chart example - MorrisJS | Capelo | 2,385 Kb |
Masonry | Uriuriuriu | 5,005 Kb |
Twitch API | Coderpilot | 3,412 Kb |
Add This API | ThatGuySam | 2,848 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
Sassy Buttons | Elyseholladay | 2,299 Kb |
Basic jQuery Filter list | Mtedwards | 2,464 Kb |
A Pen by utcwebdev | Utcwebdev | 2,856 Kb |
GLSL Hills | Ykob | 6,991 Kb |
A Pen by Jess | Jessamyne | 5,100 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!