我在css-Tricks中遵循this method来设置输入范围的样式,并尝试使用前后伪类.以下是我尝试过的代码:
input[type=range]::-webkit-slider-thumb:before {
background: #fff;
}
这似乎没有办法.有人可以帮助我如何设置滑块轨道的样式.我需要一个纯CSS解决方案.基本上我想要它到look like this.
input[type=range] {
-webkit-appearance: none;
margin: 18px 0;
width: 100%;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 8.4px;
cursor: pointer;
animate: 0.2s;
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
background: #3071a9;
border-radius: 1.3px;
border: 0.2px solid #010101;
}
input[type=range]::-webkit-slider-thumb {
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 36px;
width: 16px;
border-radius: 3px;
background: #ffffff;
cursor: pointer;
-webkit-appearance: none;
margin-top: -14px;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #367ebd;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 8.4px;
cursor: pointer;
animate: 0.2s;
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
background: #3071a9;
border-radius: 1.3px;
border: 0.2px solid #010101;
}
input[type=range]::-moz-range-thumb {
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 36px;
width: 16px;
border-radius: 3px;
background: #ffffff;
cursor: pointer;
}
input[type=range]::-ms-track {
width: 100%;
height: 8.4px;
cursor: pointer;
animate: 0.2s;
background: transparent;
border-color: transparent;
border-width: 16px 0;
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: #2a6495;
border: 0.2px solid #010101;
border-radius: 2.6px;
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
}
input[type=range]::-ms-fill-upper {
background: #3071a9;
border: 0.2px solid #010101;
border-radius: 2.6px;
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
}
input[type=range]::-ms-thumb {
Box-shadow: 1px 1px 1px #000000,0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 36px;
width: 16px;
border-radius: 3px;
background: #ffffff;
cursor: pointer;
}
input[type=range]:focus::-ms-fill-lower {
background: #3071a9;
}
input[type=range]:focus::-ms-fill-upper {
background: #367ebd;
}
最佳答案
它可能在Firefox和IE中 –
原文链接:https://www.f2er.com/html/426107.html// Mozilla
input[type="range"]::-moz-range-progress {
background: #cc1a1a;
height: 12px;
border-radius: 12px;
}
// IE
input[type="range"]::-ms-fill-lower {
background: #CC1A1A;
border: 0 solid #000101;
border-radius: 50px;
Box-shadow: 0 0 0 #000000,0 0 0 #0d0d0d;
}
input[type="range"]::-ms-fill-upper {
background: #c0c0c0;
border: 0 solid #000101;
border-radius: 50px;
Box-shadow: 0 0 0 #000000,0 0 0 #0d0d0d;
}
Chrome只有一种方式:之前和之后,不再支持(自2016年3月起).我找到的最好的 – 是http://rangeslider.js.org/.它也适用于Angular JS – https://github.com/danielcrisp/angular-rangeslider