<div class="container">
<h1>text-indent: <span id="val">100</span>% (<strong>300px</strong>) </h1>
</div>
<div class="actions">
<label for="percentage">text-indent:</label>
<input type="range" id="percentage" name="percentage" min="-200" max="200" value="100" step="5">
<span>%</span>
</div>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
width: 100vw;
min-height: 100vh;
margin: 0;
background-color: #291642;
font-family: "Gochi Hand", sans-serif;
font-size: 100%;
line-height: 150%;
letter-spacing: 0.1rem;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-blend-mode: hue;
}
.container {
display: flex;
align-items: center;
justify-content: center;
position: relative;
margin-top: auto;
}
.actions {
padding: 3vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
font-size: 2rem;
margin-top: auto;
}
:root {
--text-indent: 100%;
}
h1 {
text-indent: var(--text-indent);
border: 1px dotted #0ff;
inline-size: 300px;
block-size: 200px;
border-radius: 5px;
position: relative;
white-space: nowrap;
padding-block-start: 30%;
}
h1::before {
content: "inline-size: 300px; block-size: 200px";
position: absolute;
left: 0;
bottom: 100%;
color: #fff;
z-index: 2;
font-size: 16px;
line-height: 1.5;
text-indent: 0;
}
label {
margin: 0 10px;
}
const rangeElement = document.getElementById("percentage");
const spanElement = document.getElementById("val");
const strongElement = document.querySelector("strong");
rangeElement.addEventListener("change", (etv) => {
document.documentElement.style.setProperty(
"--text-indent",
`${etv.target.value}%`
);
spanElement.textContent = etv.target.value;
const strongElementVal = (etv.target.value * 300) / 100;
strongElement.textContent = `${strongElementVal}px`;
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.