input range exploration
by Max Shu
HTML
<div class="wrap">
<input id="myRange" class="slider" type="range" min="1" max="4" value="1">
<i> </i>
</div>
CSS
.wrap {position: relative; width: 200px; margin: 0 auto;}
input[value="1"] + i {background:red;}
input[value="2"] + i {background:green;}
input[value="3"] + i {background:turquoise;}
input[value="4"] + i {background:yellow;}
input+i {display: block; width: 100px; height: 100px; border-radius: 50%; position: absolute; left: calc(50% - 50px); top: 0; text-align: center; margin-top: 20px;}
input#myRange {margin-top: 150px;}
/* appearance generated with http://danielstern.ca/range.css/ */
input[type=range].slider {
-webkit-appearance: none;
width: 100%;
margin: 5.5px 0;
}
input[type=range].slider:focus {
outline: none;
}
input[type=range].slider::-webkit-slider-runnable-track {
width: 100%;
height: 7px;
cursor: pointer;
background: #b3b3b3;
border-radius: 25px;
}
input[type=range].slider::-webkit-slider-thumb {
height: 18px;
width: 18px;
border-radius: 50%;
background: slategray;
cursor: pointer;
-webkit-appearance: none;
margin-top: -5.5px;
}
input[type=range].slider:focus::-webkit-slider-runnable-track {
background: #d9d9d9;
}
input[type=range].slider::-moz-range-track {
width: 100%;
height: 7px;
cursor: pointer;
background: #b3b3b3;
border-radius: 25px;
}
input[type=range].slider::-moz-range-thumb {
height: 18px;
width: 18px;
border-radius: 50%;
background: slategray;
cursor: pointer;
}
input[type=range].slider::-ms-track {
width: 100%;
height: 7px;
cursor: pointer;
background: transparent;
border-color: transparent;
color: transparent;
}
input[type=range].slider::-ms-fill-lower {
background: #8d8d8d;
border-radius: 50%;
}
input[type=range].slider::-ms-fill-upper {
background: #b3b3b3;
border-radius: 50%;
}
input[type=range].slider::-ms-thumb {
height: 18px;
width: 18px;
border-radius: 50%;
background: slategray;
cursor: pointer;
height: 7px;
}
input[type=range].slider:focus::-ms-fill-lower {
background: #b3b3b3;
}
input[type=range].slider:focus::-ms-fill-upper {
...
JavaScript
$('#myRange').on('input change', function() {
$(this).attr('value', this.value);
}).change();