Do not want to have deagable funcationlaity in input type range

i want my input type range like when someone will try to drag it . it should not be a dragable . but when someone will clicl on a specific point in input type range it should move to that here is the codepen link"https://codepen.io/Talha-Mustafa/pen/LYagXQJ
1 Reply
MarkBoots
MarkBoots5mo ago
i don't think you can adjust the thumb behaviour without setting the appearance to none. So in that case you will need to style the whole input range. These are the styles that you have access too (with some example styling). To make the thumb not draggable, you could add a pointer-events: none to every selector that contains ...-thumb this is not mine, had it saved somewhere, but unfortunately didn't note who to credit for this
/********** Range Input Styles **********/
/*Range Reset*/
input[type="range"] {
-webkit-appearance: none;
appearance: none;
background: transparent;
cursor: pointer;
width: 15rem;
}

/* Removes default focus */
input[type="range"]:focus {
outline: none;
}

/***** Chrome, Safari, Opera and Edge Chromium styles *****/
/* slider track */
input[type="range"]::-webkit-slider-runnable-track {
background-color: #053a5f;
border-radius: 0.5rem;
height: 0.5rem;
}

/* slider thumb */
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; /* Override default look */
appearance: none;
margin-top: -12px; /* Centers thumb on the track */

/*custom styles*/
background-color: #5cd5eb;
height: 2rem;
width: 1rem;
}

input[type="range"]:focus::-webkit-slider-thumb {
border: 1px solid #053a5f;
outline: 3px solid #053a5f;
outline-offset: 0.125rem;
}

/******** Firefox styles ********/
/* slider track */
input[type="range"]::-moz-range-track {
background-color: #053a5f;
border-radius: 0.5rem;
height: 0.5rem;
}

/* slider thumb */
input[type="range"]::-moz-range-thumb {
border: none; /*Removes extra border that FF applies*/
border-radius: 0; /*Removes default border-radius that FF applies*/

/*custom styles*/
background-color: #5cd5eb;
height: 2rem;
width: 1rem;
}

input[type="range"]:focus::-moz-range-thumb {
border: 1px solid #053a5f;
outline: 3px solid #053a5f;
outline-offset: 0.125rem;
}
/********** Range Input Styles **********/
/*Range Reset*/
input[type="range"] {
-webkit-appearance: none;
appearance: none;
background: transparent;
cursor: pointer;
width: 15rem;
}

/* Removes default focus */
input[type="range"]:focus {
outline: none;
}

/***** Chrome, Safari, Opera and Edge Chromium styles *****/
/* slider track */
input[type="range"]::-webkit-slider-runnable-track {
background-color: #053a5f;
border-radius: 0.5rem;
height: 0.5rem;
}

/* slider thumb */
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; /* Override default look */
appearance: none;
margin-top: -12px; /* Centers thumb on the track */

/*custom styles*/
background-color: #5cd5eb;
height: 2rem;
width: 1rem;
}

input[type="range"]:focus::-webkit-slider-thumb {
border: 1px solid #053a5f;
outline: 3px solid #053a5f;
outline-offset: 0.125rem;
}

/******** Firefox styles ********/
/* slider track */
input[type="range"]::-moz-range-track {
background-color: #053a5f;
border-radius: 0.5rem;
height: 0.5rem;
}

/* slider thumb */
input[type="range"]::-moz-range-thumb {
border: none; /*Removes extra border that FF applies*/
border-radius: 0; /*Removes default border-radius that FF applies*/

/*custom styles*/
background-color: #5cd5eb;
height: 2rem;
width: 1rem;
}

input[type="range"]:focus::-moz-range-thumb {
border: 1px solid #053a5f;
outline: 3px solid #053a5f;
outline-offset: 0.125rem;
}