Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!