I have to achieve this: Range Slider
I have done the range slider part but I am facing issues while changing the marker over range slider. Even I am providing the image src : "https://png.icons8.com/metro/52/000000/sort-down.png".
I am adding my work upto where I have completed.
var slider = document.getElementById("myRange");
var output = document.getElementById("demo");
.slidecontainer {
width: 100%;
}
.slider {
width: 30%;
height: 10px;
border-radius: 5px;
background-image: linear-gradient(to right, rgba(255, 0, 0, 1), rgba(0, 128, 0, 1));
outline: none;
opacity: 0.7;
transition: opacity .2s;
-webkit-appearance: none;
}
.slider:hover {
background-image: linear-gradient(to right, rgba(255, 0, 0, 1), rgba(0, 128, 0, 1));
}
.slider::-webkit-slider-thumb {
width: 23px;
height: 24px;
border: 0;
background: url('contrasticon.png');
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 23px;
height: 24px;
border: 0;
background: url('contrasticon.png');
cursor: pointer;
}
<div class="slidecontainer">
<input type="range" min="1" max="100" value="50" class="slider" id="myRange">
</div>
You need to use appearance: none;
on the slider thumb to use a custom image.
Have a look:
.slidecontainer {
width: 100%;
}
.slider {
width: 30%;
height: 10px;
border-radius: 5px;
background-image: linear-gradient(to right, rgba(255, 0, 0, 1), rgba(0, 128, 0, 1));
outline: none;
opacity: 0.7;
transition: opacity .2s;
-webkit-appearance: none;
}
.slider:hover {
background-image: linear-gradient(to right, rgba(255, 0, 0, 1), rgba(0, 128, 0, 1));
}
.slider::-webkit-slider-thumb {
width: 23px;
height: 24px;
border: 0;
background: url('https://png.icons8.com/metro/52/000000/sort-down.png');
background-size: 16px;
background-repeat: no-repeat;
background-position: 0 -4px;
cursor: pointer;
-webkit-appearance: none;
}
.slider::-moz-range-thumb {
width: 23px;
height: 24px;
border: 0;
background: url('https://png.icons8.com/metro/52/000000/sort-down.png');
background-size: 16px;
background-repeat: no-repeat;
background-position: 0 -4px;
cursor: pointer;
-moz-appearance: none;
}
<div class="slidecontainer">
<input type="range" min="1" max="100" value="50" class="slider" id="myRange">
</div>
Now feel free to change the image property like size, rotation, z-index whatever you need