Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
How to change color, size and shape of elements in a range slider?

I don't have any expertise in coding or web development. After hours of research in Google, I ended up writing a set of (perfectly working) codes to build a range slider with HTML, CSS and JS.

I'm using this slider to change media volume in my smartphone, in this Media Control Panel created using an Android application called Tasker. My slider is functional, but I want to make some cosmetic changes to my slider.

Could someone please help me to implement following into my code?

  1. Color / gradient of the slider portion before the thumb.
  2. Color / gradient of the slider portion after the thumb.
  3. Size, shape, color, and opacity of the thumb.

This is the current code. Feel free to edit this.

<div class = "container">
    <input type="range" 
    min="0" 
    max="25" 
    step="any" 
    value="%VOLM" 
    id="volm">
</div>

<style>
.container{
    display:flex;
    width:100%;
    padding-top:5
}

#volm{
    -webkit-appearance: none;
    background-color: magenta;
    border-radius: 2px;
    width:153px;
    height:5px;
</style>

<script>
    var slider = document.getElementById("volm");
    slider.addEventListener("input",function() 
{
    performTask("WebView Slider - Media Volume",1,slider.value,)}, false);
</script>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

HTML Range Input has the following two pseudo-elements:

  1. -webkit-slider-runnable-track
  2. -webkit-slider-thumb

You can style them using the pseudo-selectors. This CodePen has a clever solution in achieving what you intend. By using box-shadows on the thumb, you can style the area before and after the thumb. Use multiple box-shadows + blurring to achieve gradient-like effects.

I edited your code a little to show how the above can be achieved. Rest is just about preferences on how you want the slider to look like. You can also use JavaScript to dynamically change property values depending on the input.

.container{
    display:flex;
    width:100%;
    padding-top:5;
    height: fit-content;
}

#volm{
    position: relative;
    margin-top: 5px;
    border-radius: 2px;
    width:153px;
    height: 5px;
    -webkit-appearance: none;
}
input::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  position: relative;
  box-sizing: border-box;
  background-color: hsl(0deg, 0%, 90%);
  width: 100%;
  height: 20px;
  border-radius: 5px;
  overflow: hidden;
} 
input::-webkit-slider-thumb {
  position: relative;
  left: initial;
  bottom: 5px;
  -webkit-appearance: none;
  background-color: blue;
  width: 20px;
  height: 20px;
  border-radius: 20px;
  box-shadow: -340px 0 0 320px #1597ff, inset 0 0 0 40px #1597ff, 340px 0 0 320px #00f18f, inset 0 0 0 40px #1597ff;
  margin-top: 5px;
}
<div class = "container">
    <input type="range" 
    min="0" 
    max="25" 
    step="any" 
    value="%VOLM" 
    id="volm">
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda