<div class="container range__slant">
<div class="paragraph">
<div class="text">Variable Fonts</div>
</div>
<div id='demo-controls' class="controls">
<!-- Weight -->
<div class="value-tag"></div>
<div class="low-value"></div>
<div class="slider range-width">
<input type="range" name="range-weight" value="400" id="text-vf-wght" class="controls--weight" min="100" max="700">
<label for="controls__weight">Weight</label>
</div>
<div class=" high-value"></div>
<div class=" current-value"></div>
<!-- Width -->
<div class="value-tag2"></div>
<div class="low-value2"></div>
<div class="slider range-width">
<input type="range" name="range-width" value="95" id="text-vf-wdth" class="controls--width" min="85" max="100">
<label for="controls__width">Width</label>
</div>
<div class="high-value2"></div>
<div class="current-value2"></div>
<!-- Slant -->
<div class="value-tag3"></div>
<div class="low-value3"></div>
<div class="slider range-slant">
<input type="range" name="range-slant" value="9" id="text-vf-slnt" class="controls--slant" min="0" max="15">
<label for="controls__slant">Slant</label>
</div>
<div class="high-value3"></div>
<div class="current-value3"></div>
<!-- Italic -->
<div class="value-tag4"></div>
<div class="low-value4"></div>
<div class="slider range-italic">
<input type="range" name="range-italic" value="0" id="text-vf-ital" class="controls--slant" min="0" max="1">
<label for="controls__slant">Italic</label>
</div>
<div class="high-value4"></div>
<div class="current-value4"></div>
<!-- Optical Size -->
<div class="value-tag5"></div>
<div class="low-value5"></div>
<div class="slider range-width">
<input type="range" name="range-opsz" value="80" id="text-vf-opsz" class="controls--opsz" min="8" max="144"> <label for="controls__width">Optical Size</label>
</div>
<div class="high-value5"></div>
<div class="current-value5"></div>
</div>
</div>
@font-face {
font-family: "Amstelvar VF";
src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/57225/Amstelvar-Roman-VF_copy.woff2")
format("woff2 supports variations"), url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/57225/Amstelvar-Roman-VF_copy.woff2")
format("woff2-variations");
font-display: swap;
font-weight: 100 900;
font-stretch: 75% 125%;
}
.range__slant {
--text-vf-wght: 400;
--text-vf-wdth: 95;
--text-vf-slnt: 9;
--text-vf-ital: 0;
--text-vf-opsz: 80;
--value-tag: 'wght';
--low-value: 100;
--current-value: var(--text-vf-wght);
--high-value: 700;
--value-tag2: 'wdth';
--low-value2: 85;
--current-value2: var(--text-vf-wdth);
--high-value2: 100;
--value-tag3: 'slnt';
--low-value3: 0;
--current-value3: var(--text-vf-slnt);
--high-value3: 15;
--value-tag4: 'ital';
--low-value4: 0;
--current-value4: var(--text-vf-ital);
--high-value4: 1;
--value-tag5: 'opsz';
--low-value5: 8;
--current-value5: var(--text-vf-opsz);
--high-value5: 144;
.paragraph {
background-color: #ffffff;
margin-left: auto;
margin-right: auto;
max-width: 95vw;
width: 45em;
flex:1;
}
.paragraph .text {
font-family: "Amstelvar VF", Helvetica, sans-serif;
font-size: 5rem;
// font-weight: var(--text-vf-wght);
font-variation-settings:"wght" var(--text-vf-wght), "wdth" var(--text-vf-wdth), "slnt" calc( var(--text-vf-slnt) * -1), "ital" var(--text-vf-ital), "opsz" var(--text-vf-opsz), "MONO" 0, "CASL" 0;
line-height: 7rem;
margin: 0 auto 0 auto;
text-align: center;
}
/* Control buttons */
.controls {
display: grid;
grid-template-columns: min-content 1fr min-content;
margin: 0 2em;
text-align: center;
width: 20rem;
h3 {
display: inline;
font-weight: normal;
font-family: monospace;
}
label {
float: left;
height: 1px;
text-indent: -999em;
visibility: hidden;
}
.slider {
grid-column: 2/3;
input {
width: 100%;
}
}
.value-tag {
grid-column: span 3;
font-weight: bold;
margin-bottom: 0.5rem;
text-align: left;
&::before {
counter-reset: tag var(--value-tag);
content: "'" var(--value-tag) "' range";
font-family: sans-serif;
}
}
.low-value {
grid-column: 1/2;
text-align: left;
width: 2.5rem;
&::before {
counter-reset: tag var(--low-value);
content: counter(tag);
font-family: sans-serif;
}
}
.high-value{
grid-column: 4/5;
text-align: right;
width: 2.5rem;
&::before {
counter-reset: tag var(--high-value);
content: counter(tag);
font-family: sans-serif;
}
}
.current-value {
grid-column: 2/3;
&::before {
counter-reset: tag var(--current-value);
border: solid 1px black;
content: counter(tag);
display: inline-block;
font-family: sans-serif;
min-width: 3rem;
margin: 0 auto;
padding: 0.25rem 0.25rem 0.2rem 0.25rem;
}
}
.value-tag2 {
grid-column: span 3;
font-weight: bold;
margin-bottom: 0.5rem;
text-align: left;
&::before {
counter-reset: tag var(--value-tag2);
content: "'" var(--value-tag2) "' range";
font-family: sans-serif;
}
}
.low-value2 {
grid-column: 1/2;
text-align: left;
width: 2.5rem;
&::before {
counter-reset: tag var(--low-value2);
content: counter(tag);
font-family: sans-serif;
}
}
.high-value2 {
grid-column: 4/5;
text-align: right;
width: 2.5rem;
&::before {
counter-reset: tag var(--high-value2);
content: counter(tag);
font-family: sans-serif;
}
}
.current-value2 {
grid-column: 2/3;
&::before {
counter-reset: tag var(--current-value2);
border: solid 1px black;
content: counter(tag);
display: inline-block;
font-family: sans-serif;
min-width: 3rem;
margin: 0 auto;
padding: 0.25rem 0.25rem 0.2rem 0.25rem;
}
}
.value-tag3 {
grid-column: span 3;
font-weight: bold;
margin-bottom: 0.5rem;
text-align: left;
&::before {
counter-reset: tag var(--value-tag3);
content: "'" var(--value-tag3) "' range";
font-family: sans-serif;
}
}
.low-value3 {
grid-column: 1/2;
text-align: left;
width: 2.5rem;
&::before {
counter-reset: tag var(--low-value3);
content: counter(tag);
font-family: sans-serif;
}
}
.high-value3 {
grid-column: 4/5;
text-align: right;
width: 2.5rem;
&::before {
counter-reset: tag var(--high-value3);
content: counter(tag);
font-family: sans-serif;
}
}
.current-value3 {
grid-column: 2/3;
&::before {
counter-reset: tag var(--current-value3);
border: solid 1px black;
content: counter(tag);
display: inline-block;
font-family: sans-serif;
min-width: 3rem;
margin: 0 auto;
padding: 0.25rem 0.25rem 0.2rem 0.25rem;
}
}
.value-tag4 {
grid-column: span 3;
font-weight: bold;
margin-bottom: 0.5rem;
text-align: left;
&::before {
counter-reset: tag var(--value-tag4);
content: "'" var(--value-tag4) "' range";
font-family: sans-serif;
}
}
.low-value4 {
grid-column: 1/2;
text-align: left;
width: 2.5rem;
&::before {
counter-reset: tag var(--low-value4);
content: counter(tag);
font-family: sans-serif;
}
}
.high-value4 {
grid-column: 4/5;
text-align: right;
width: 2.5rem;
&::before {
counter-reset: tag var(--high-value4);
content: counter(tag);
font-family: sans-serif;
}
}
.current-value4 {
grid-column: 2/3;
&::before {
counter-reset: tag var(--current-value4);
border: solid 1px black;
content: counter(tag);
display: inline-block;
font-family: sans-serif;
min-width: 3rem;
margin: 0 auto;
padding: 0.25rem 0.25rem 0.2rem 0.25rem;
}
}
.value-tag5 {
grid-column: span 3;
font-weight: bold;
margin-bottom: 0.5rem;
text-align: left;
&::before {
counter-reset: tag var(--value-tag5);
content: "'" var(--value-tag5) "' range";
font-family: sans-serif;
}
}
.low-value5 {
grid-column: 1/2;
text-align: left;
width: 2.5rem;
&::before {
counter-reset: tag var(--low-value5);
content: counter(tag);
font-family: sans-serif;
}
}
.high-value5 {
grid-column: 4/5;
text-align: right;
width: 2.5rem;
&::before {
counter-reset: tag var(--high-value5);
content: counter(tag);
font-family: sans-serif;
}
}
.current-value5 {
grid-column: 2/3;
&::before {
counter-reset: tag var(--current-value5);
border: solid 1px black;
content: counter(tag);
display: inline-block;
font-family: sans-serif;
min-width: 3rem;
margin: 0 auto;
padding: 0.25rem 0.25rem 0.2rem 0.25rem;
}
}
}
}
body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
}
.container {
display: flex;
width: 100vw;
align-items: center;
}
View Compiled
// get the inputs
const inputs = [].slice.call(document.querySelectorAll('.range__slant .controls input'));
// listen for changes
inputs.forEach(input => input.addEventListener('change', handleUpdate));
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
function handleUpdate(e) { document.querySelector('.range__slant').style.setProperty(`--${this.id}`, this.value);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.