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

116
Visualizações
How to make a parallax effect on background image when changing the ranger slider?

I am trying to create a parallax effect on the background image when I move the slider. I decided to just change the position of the background on the image, but I'm not entirely sure that's a good solution. Please tell me how to improve such an effect so that the picture on the background moves more smoothly, so that it is really called parallax.

const p = document.getElementById("price");
const bg = document.getElementById("bg");

p.addEventListener("input", function() {
        bg.style.backgroundPosition = `${p.value}% 50%`;
}, false); 
.parent {
  display: flex;
  width: 500px;
  height: 300px;
  justify-content: center;
  align-items: center;
  background-image: url('https://wallpaperaccess.com/full/99840.jpg');
  background-size: cover;
  background-repeat: no-repeat;
}

.child {
  width: 50%;
  background-color: #fff;
  padding: 5%;
}
<input id="price" type="range" value="" />

<div class="parent" id="bg">
  <div class="child">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam officia voluptatem, sint voluptatibus. Cumque vel voluptatem voluptatibus quisquam corporis nam, fugit maxime, architecto similique natus, ipsam enim eveniet recusandae odio.
  </div>
</div>

about 4 years ago · Santiago Gelvez
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