如何使用CSS3和Javascript创建双范围滑块?

时间:2015-02-14 14:28:17

标签: javascript jquery html css rangeslider

我试图通过使用两个范围元素来创建价格范围 像这样:

CSS代码:

.first{
    position : relative;
    top :10px;
    left :10px;
    margin : 0;
    padding : 0;
    border : 1px solid red;
    border-top : 4px solid transparent;
    border-radius :3px;
    z-index:0;
}

.next{
    position : relative;
    top :0px;
    left :-153px; 
    margin : 0;
    padding : 0;
    border : 1px solid red;
    border-bottom : 1px solid transparent;
    border-radius :3px;
    z-index : 4;
}

HTML code:

<span>price :</span>
<input class ="first" type="range" min="0" max="10000" step="100" value="0" multiple>
<input class ="next" type="range" min="0" max="10000" step="100" value="10000" multiple>

是否可以将主题设置为看起来像jQuery范围滑块?

1 个答案:

答案 0 :(得分:-1)

CSS代码:

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-ms-track {
    width: 100%;
    cursor: pointer;
    background: transparent;
    border-color: transparent;
    color: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    border: 1px solid #d3d3d3;
    height: 16px;
    width: 16px;
    border-radius: 3px;
    background: #e6e6e6;
    cursor: pointer;
    margin-top: -3px;
}

input[type=range]::-webkit-slider-thumb:hover {
    background: #DADADA;
    border: 1px solid #999999;
}

input[type=range]::-moz-range-thumb {
    -moz-appearance: none;
    border: 1px solid #d3d3d3;
    height: 16px;
    width: 16px;
    border-radius: 3px;
    background: #e6e6e6;
    cursor: pointer;
}

input[type=range]::-ms-thumb {
    border: 1px solid #d3d3d3;
    height: 16px;
    width: 16px;
    border-radius: 3px;
    background: #e6e6e6;
    cursor: pointer;
}

input[type=range]::-ms-thumb:hover {
    background: #DADADA;
    border: 1px solid #999999;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: #FFF;
    border-radius: 5px;
    border: 1px solid #010101;
}

input[type=range]:focus::-webkit-slider-runnable-track {
    background: #FFF;
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: #FFF;
    border-radius: 5px;
    border: 1px solid #aaaaaa;
}

input[type=range]::-ms-track {
    width: 100%;
    height: 12px;
    cursor: pointer;
    background: transparent;
    border-color: transparent;
    border-width: 16px 0;
    color: transparent;
}

input[type=range]::-ms-fill-lower {
    background: #2a6495;
    border: 1px solid #aaaaaa;
    border-radius: 2.6px;
}

input[type=range]:focus::-ms-fill-lower {
    background: #FFF;
}

input[type=range]::-ms-fill-upper {
    background: #FFF;
    border: 1px solid #aaaaaa;
    border-radius: 5px;
}

input[type=range]:focus::-ms-fill-upper {
    background: #FFF;
}