Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
How to make off-centered range input?

I have a range input, by default, its center is 50 points of 100. I need 20 points in center, but leave max of 100. How to do it? (image example)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is entirely up to you. The actual input range wll be linear but how your code interprets the value it gets back is in your control.

So set the range on the input to min 0 and max 100. But when you get the value in Javascript you interpret it as you wish.

The simplest curve you can fit to the values (x1, y1), (x2, y2), (x3, y3) is a parabola: y1 = ax1x1 + b*x1 + c; and so on

Solving these three simultaneous equations for your points (0, 0), (50, 20), (100, 100) we get: a=3/250; b=-0.2; c=0;

function getValue(v) {
  document.querySelector('#value').innerHTML = 3 / 250 * v * v - 0.2 * v;
}
getValue(document.querySelector('input').value);
<input type="range" min=0 max=100 onchange="getValue(this.value);">
<div>The calculated value is <span id="value"></span></div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda