我正在关注这个方法 http://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/来自 CSS-Tricks 来设置输入范围的样式,并尝试使用之前和之后的伪类。下面是我尝试过的代码:
input[type=range]::-webkit-slider-thumb:before {
background: #fff;
}
这似乎并不能解决问题。有人可以帮助我如何设计滑块轨道的样式吗?我需要一个纯CSS解决方案。本质上我想要它看起来像这样 https://i.stack.imgur.com/xRp5q.png.
我还将粘贴 CSS-Tricks 中的代码:
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 中是可能的 -
// 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:before
and :after
,不再受支持(自 2016 年 3 月起)。我发现的最好的 - 是http://rangeslider.js.org/ http://rangeslider.js.org/。它也可以与 Angular JS 配合使用 -https://github.com/danielcrisp/angular-rangeslider https://github.com/danielcrisp/angular-rangeslider
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)