<div class="container">
<h1>font-size: <span id="val">100</span>%</h1>
</div>
<div class="actions">
<label for="percentage">font-size:</label>
<input type="range" id="percentage" name="percentage" min="10" max="300" 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%;
letter-spacing: 0.1rem;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
background-blend-mode: hue;
}
.container {
flex: 1;
min-height: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.actions {
padding: 3vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
font-size: 2rem;
}
:root {
--font-size: 100%;
}
h1 {
display: inline-flex;
font-size: var(--font-size);
background: linear-gradient(to right, #44ea76 0%, #39fad7 80%, #39fad7 100%)
no-repeat,
url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/slider-2.jpg")
no-repeat fixed;
background-size: cover;
background-clip: text;
-webkit-text-fill-color: transparent;
}
const rangeElement = document.getElementById("percentage");
const spanElement = document.getElementById("val");
rangeElement.addEventListener("change", (etv) => {
document.documentElement.style.setProperty(
"--font-size",
`${etv.target.value}%`
);
val.textContent = etv.target.value;
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.