Input range / New tipo
by Léo Durand
HTML
<form name="rangesSVG">
<input type="range" id="widthInput" value="24" min="1" max="100" oninput="widthOutput.value = widthInput.value">
<output id="widthOutput" class="value-param">24px</output>
</form>
<div id="para">
Hello
</div>
CSS
html {
background: #1a1a1a;
}
*:focus {
outline: none;
}
input[type=range] {
-webkit-appearance: none;
width: 140px;
background: transparent;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
background: #11d496;
height: 18px;
width: 18px;
border: 3px solid white;
border-radius: 10px;
margin-top: -6px;
transition: 0.1s ease;
}
input[type=range]:focus::-webkit-slider-thumb {
background: grey;
height: 14px;
width: 14px;
border: 4px solid white;
border-radius: 10px;
margin-top: -4px;
transition: 0.1s ease;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 6px;
border-radius: 3px;
cursor: pointer;
background: #ececec;
transition: 0.3s ease;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #d5d5d5;
transition: 0.3s ease;
}
.value-param {
width: 50px;
color: grey;
font-family: Maison Mono;
font-size: 10pt;
text-align: right;
margin-top:4px;
position: absolute;
}
#para{
color:white;
font-size:24px;
margin-top:50px;
}
JavaScript
document.rangesSVG.widthInput.oninput = function(){
value = document.rangesSVG.widthInput.value;
document.rangesSVG.widthOutput.value = document.rangesSVG.widthInput.value;
document.rangesSVG.widthOutput.value = document.getElementById("para").style.fontSize = value + "px";
}