我搜索了一段时间,但没有找到任何有用的东西。我有以下 css
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 20px;
height: 20px;
border-radius: 10px;
background-image: url('http://www.w3schools.com/html/smiley.png'),
-webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, #fefefe),
color-stop(0.49, #dddddd),
color-stop(0.51, #d1d1d1),
color-stop(1, #a1a1a1)
);
background-size:20px;
background-repeat: no-repeat;
现在我想借助 jquery 或我可以从 chrome 控制台测试的纯 javascript 将背景图像更改为其他图像 src。所以我有类似的东西:
`background-image: url('http://someotherimage/test.png'),`
谁能提到正确的语法。 感谢您期待好评。
最佳答案
input[type=range] {
-webkit-appearance: none;
width: 100%;
margin: 50px 0;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 8.4px;
cursor: pointer;
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 {
height: 50px;
width: 50px;
border-radius: 3px;
background-color: transparent;
background: url(/image/QneFV.png) center center no-repeat;
cursor: pointer;
-webkit-appearance: none;
margin-top: -23px;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #367ebd;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 8.4px;
cursor: pointer;
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 {
height: 50px;
width: 50px;
border-radius: 3px;
background-color: transparent;
background: url(/image/QneFV.png) center center no-repeat;
cursor: pointer;
-webkit-appearance: none;
margin-top: -23px;
}
input[type=range]::-ms-track {
width: 100%;
height: 8.4px;
cursor: pointer;
background: transparent;
border-color: transparent;
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 {
height: 50px;
width: 50px;
border-radius: 3px;
background-color: transparent;
background: url(/image/QneFV.png) center center no-repeat;
cursor: pointer;
-webkit-appearance: none;
margin-top: -23px;
}
input[type=range]:focus::-ms-fill-lower {
background: #3071a9;
}
input[type=range]:focus::-ms-fill-upper {
background: #367ebd;
}
<input type="range" />
关于javascript - 通过 jquery 更改 webkit-slider-thumb 的背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24651449/