input type range css - background color(输入类型范围 css - 背景颜色)
本文介绍了输入类型范围 css - 背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 css 自定义 <input type="range">
.我想要达到的结果是这样的:
I want to customize the <input type="range">
using css. The result I want to achieve is this:
但是我下面的代码给了我这个
but my following code gives me this
这是我的代码:
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;
}
是否可以将滑块分为活动"和非活动"?
Is it possible to separate the slider into "active" and "inactive" one?
提前致谢达里奥
推荐答案
希望例子对你有所帮助
代码:示例
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('');
};
}
});
这篇关于输入类型范围 css - 背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:输入类型范围 css - 背景颜色


猜你喜欢
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01