<div class="text-shadow" contenteditable>Hello World !</div>
<div class="code">
<pre id="result"></pre>
</div>
<form class="form">
<span>text-shadow:</span>
<label for="x-offset">x-offset:</label>
<input type="number" enterkeyhint="enter" min="-100" max="100" value="5" step="1" id="x-offset" name="x-offset" />
<label for="y-offset">y-offset:</label>
<input type="number" enterkeyhint="enter" min="-100" max="100" value="5" step="1" id="y-offset" name="y-offset" />
<label for="blur-radius">blur-radius:</label>
<input type="number" enterkeyhint="enter" min="0" max="100" value="5" step="1" id="blur-radius" name="blur-radius" />
<label for="color">color:</label>
<input type="color" value="#09fa00" id="color" name="color" />
</form>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
font-family: "Exo", Arial, sans-serif;
background-color: #557;
color: #fff;
display: grid;
grid-template-columns: 1fr max-content;
gap: 1.25rem;
}
.form {
grid-column: 2 / 3;
grid-row: 1 / span 2;
background: rebeccapurple;
display: grid;
grid-template-columns: max-content 1fr;
gap: 10px;
align-content: start;
padding: 20px;
min-width: 20vw;
font-family: "Exo", Arial, sans-serif;
}
.form span {
grid-column: 1 / -1;
}
.form input {
display: inline-flex;
padding: 5px 10px;
justify-self: start;
border-radius: 4px;
min-width: 80px;
min-height: 2.5rem;
}
.form label {
align-self: center;
text-align: right;
}
.form input[type="color"] {
padding: 0;
}
input[type="color" i]::-webkit-color-swatch-wrapper {
padding: 0;
border: none 0;
border-radius: 4px;
}
.text-shadow {
justify-self: center;
align-self: center;
font-size: clamp(1.5rem, 1.5rem + 3vw, 3rem);
}
.code {
justify-self: center;
align-self: start;
font-size: clamp(1rem, 1rem + 2vw, 1.5rem);
}
:root {
--x-offset: 5;
--y-offset: 5;
--blur-radius: 5;
--color: #09fa00;
}
.text-shadow {
text-shadow: calc(var(--x-offset) * 1px) calc(var(--y-offset) * 1px)
calc(var(--blur-radius) * 1px) var(--color);
}
const offsetX = document.querySelector("#x-offset");
const offsetY = document.querySelector("#y-offset");
const blur = document.querySelector("#blur-radius");
const color = document.querySelector("#color");
const rootElement = document.documentElement;
const resultElement = document.querySelector("#result");
const render = () => {
const result = `text-shadow: ${offsetX.value}px ${offsetY.value}px ${blur.value}px ${color.value};`;
resultElement.innerHTML = `<code>${result}</code>`;
};
render();
[offsetX, offsetY, blur, color].forEach((input, index) => {
input.addEventListener("change", (etv) => {
render();
rootElement.style.setProperty(`--${etv.target.id}`, `${etv.target.value}`);
});
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.