Aschab Aschab - 1 month ago 12
CSS Question

Position pseudoelement between track and thumb of input type range

I need to put a pseudo element with z index lower than the thumb of an input type range but higher than the track of it, I got the following:

html:

<div class="range">
<input type="range" name="" class="progress" value="0" max="100" min="0" />
</div>


.range{
white-space: nowrap;
position: relative;
margin: 0 auto;
width: 50vw;
}

.range::before{
content: '';
display: inline-block;
position: absolute;
top: 2px;
width: 13px;
height: 13px;
-moz-border-radius: 13px;
-webkit-border-radius: 13px;
border-radius: 13px;
border: 2px solid #FFE000;
background-color: #242526;
z-index: 50;
}

input[type=range] {
position: absolute;
-webkit-appearance: none;
margin: 10px 0;
width: calc(100% - 15px);
display: inline-block;
vertical-align: middle;
padding: 0;
border: none;
z-index: 100;
}


input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 3px;
cursor: pointer;
animate: 0.2s;
box-shadow: 0px 0px 0px #000000;
background: #FFE000;
border-radius: 7px;
border: 0px solid #FFE000;
z-index: 0;
}


the z-index is working for the full pseudoelement and the full range, but I havent managed to put it in between. Is this possible?

Here's a working jsfiddle

Answer

Something like this i suppose: https://jsfiddle.net/cn5va061/2

Changed Z-index on before element and gave slider thumb Relative positioning for upper z-index

Comments