javascript - How can I use a different color to fill the left side of the input[type="range"] in chrome using CSS? -
as can see below in ie slider working, can't find "ms-fill-lower" pseudo-code in chrome/firefox. haven't figured out how can print out number continously above thumb (i thinking creating new childnode in js , using position of slider + current value of thumb , info create new position brand new childnode. there easier way maybe?)
<!doctype:html> <html> <head> <style> input { position: fixed; top: 40; right: 40; } input[type=range] { -webkit-appearance: none; margin: 30px 0px; width: 80%; } input[type=range]:focus { outline: none; } input[type=range]::-ms-thumb { box-shadow: 0px 0px 0px #ffccff, 0px 0px 0px #ffccff; height: 30px; width: 48px; background-image: url('https://scontent-vie1-1.xx.fbcdn.net/hphotos-xpa1/v/t34.0-12/12204684_1096899726988871_1886399559_n.jpg?oh=b8481694391b1a5ebe58733f0638a08f&oe=563669c2'); cursor: pointer; -webkit-appearance: none; margin-top: 0px; } input[type=range]::-ms-track { width: 100%; height: 30px; cursor: pointer; animate: 0.2s; background: transparent; border-color: transparent; color: transparent; } input[type=range]::-ms-fill-lower { background: #ff0000; border: 0.2px solid #ff0000; } input[type=range]::-ms-fill-upper { background: #ffccff; } input[type=range]:focus::-ms-fill-lower { background: #ff0000; } input[type=range]:focus::-ms-fill-upper { background: #ffccff; } </style> </head> <body> <input type="range"></input> </body> </html>
pseudo elements chrome ::-webkit-slider-thumb
, ::-webkit-slider-runnable-track
firefox ::-moz-range-thumb
, ::-moz-range-track
print number continuously
<input type="range" max="22" min="12" value="18" step="2" oninput="dataupdate()" id="myinput" /> <p id="mydata"></p> <script> function dataupdate(){ var x = document.getelementbyid("myinput").value; document.getelementbyid("mydata").innerhtml=x; } </script>
where value
current position of range on load, step
difference between each value, oninput
event trigger when you'll move range's thumb , output displayed in <p>
tag
to check pseudo elements in chrome can read http://webcomponents.org/articles/introduction-to-shadow-dom/
Comments
Post a Comment