【发布时间】:2017-03-23 12:01:46
【问题描述】:
我正在使用 CSS 设计 input[type=range],并使用 thumb 和 track 完成。
所有三个(-ms、-moz、-webkit)浏览器都有正确的前缀。
但是,我不知道什么供应商前缀适合在 Webkit 浏览器(例如 Chrome)上设置 progress 样式。
在 Internet Explorer 和 Microsoft Edge 上,-ms-fill-lower 效果很好。
在 Firefox 上,使用 -moz-range-progress 解决了这个问题。
input[type=range] {
/*removes default webkit styles*/
-webkit-appearance: none;
/*fix for FF unable to apply focus style bug */
border: 1px solid white;
/*required for proper track sizing in FF*/
width: 350px;
}
/* Webkit, Chrome & Safari */
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ccc;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #004d66;
margin-top: -7px;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ddd;
}
/* moz://a Firefox */
input[type=range]::-moz-range-track {
/* width: 150px;
height: 5px; */
background: #ccc;
border: none;
border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #004d66;
}
input[type=range]::-moz-range-progress {
background: #33ccff;
border-radius: 10px;
height: 5px;
}
/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid white;
outline-offset: -1px;
}
/* Microsoft */
input[type=range]::-ms-track {
height: 2px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color: transparent;
border-width: 6px 0;
/*remove default tick marks*/
color: transparent;
}
input[type=range]::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #004d66;
margin-top: 1px;
}
input[type=range]::-ms-fill-lower {
background: #33ccff;
border-radius: 10px;
height: 5px;
}
input[type=range]::-ms-fill-upper {
background: #ccc;
border-radius: 10px;
}
input[type=range]:focus::-ms-fill-lower {
background: #44ddff;
}
input[type=range]:focus::-ms-fill-upper {
background: #ddd;
}
<input type="range" />
我已经阅读了Styling input range for webkit with pure CSS,并尝试过我的,
但是当多个输入[type=range]在一个文档上时,它会奇怪地工作。
所以,问题是,
是否有任何适当的供应商前缀用于设置拇指已经通过的样式轨道,仅使用 CSS?
【问题讨论】:
-
您能否提供minimal reproducible example,最好在问题中作为sn-p。
-
@MrLister 我添加了我的样式表。 This 代码是我的基础。