html - 输入类型范围 css - 背景颜色

标签 html css slider

<分区>

我想自定义 <input type="range">使用 CSS。我想要达到的结果是这样的:

但是我下面的代码给了我这个

这是我的代码:

input[type='range'] {
    border-radius: 5px;
    height: 6px;
    vertical-align: middle;
    -webkit-appearance: none;
}
input[type="range"]::-moz-focus-inner:focus{   
    border : 0px;
    outline: 0;
} 
input[type='range']::-moz-range-track {
    border-radius: 5px;
    background-color: #E71D49;
    height: 6px;
    border: 1px dotted transparent !important;
}
input[type='range']::-webkit-slider-thumb {
    border-radius: 20px;
    background-color: #FFF;
    border:none;
    box-shadow: 0 5px #000;
    height: 5px;
    width: 5px;
}
input[type='range']::-moz-range-thumb {
    border-radius: 20px;
    background-color: #fff;
    border:none;
    height: 20px;
    box-shadow: 3px 2px 3px #000;
    width: 20px;
}

是否可以将 slider 分为“事件”和“非事件”?

提前致谢 达里奥

最佳答案

希望例子对你有帮助

代码:example

var inputs = document.getElementsByTagName('input');
inputs = Array.splice(inputs, 0);
inputs.forEach(function (item) {
if (item.type === 'range') {
    item.onchange = function () {
        value = (item.value - item.min)/(item.max - item.min)
        item.style.backgroundImage = [
            '-webkit-gradient(',
              'linear, ',
              'left top, ',
              'right top, ',
              'color-stop(' + value + ', blue), ',
              'color-stop(' + value + ', red)',
            ')'
        ].join('');
    };
}
});

关于html - 输入类型范围 css - 背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22295498/

相关文章:

html - 下拉列表由 slider html 隐藏

jquery - slick.js 错误 : "Uncaught TypeError: Cannot read property ' add' of null"

iphone - 在trigger iO中使用不同的设备

javascript - 我需要在 html 中使用 javascript 使图像变暗

html - 我正在尝试在 css 中制作一个标题,在浏览器中拉伸(stretch)全宽

javascript - 在 mousemove 上的 div 问题后圈出

javascript - 文本自动字体大小

PHP 通过两次选择循环遍历 mysql 结果并创建一个对齐的 html 表

html - 尝试使其适合元素时背景图像被切断

ios - swift 3 : How to add UISlider?