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

247
Views
Agregue un evento de desplazamiento para resaltar el color de fondo de cada fase

Estoy tratando de agregar un evento de desplazamiento que resaltará el color de fondo de cada fase, ¿alguna sugerencia? este es mi codigo html

Lo intenté con algunas opciones de escucha pero no tuve suerte.

 document.addEventListener("scroll", myFunction) function myFunction() { if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) { document.getElementById("phases2").className = "background-scroll"; } else { if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) { document.getElementById("phases2").className = "nobackground"; } else { document.getElementById("phases3").className = "background-scroll"; } } }
 .background-scroll { background-color: rgb(0, 0, 0, 0.521); border-radius: 20px; } .nobackground { background-color: rgba(0, 0, 0, 0); }
 <section class="phases"> <div class="row-padding"> <div class="row"> <div class="phases-col" id="phases2"> <img class="phases1" src="/images/1645177223057.png" /> <h3>Phase1</h3> <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Repellendus, minus eius earum necessitatibus reprehenderit, excepturi soluta, cumque sed maiores in doloremque assumenda? Eum, officia? Praesentium aspernatur neque atque numquam iste.</p> </div> <div class="phases-col"> <img class="phases1" src="/images/1645177161131.png" /> <h3>Phase2</h3> <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Repellendus, minus eius earum necessitatibus reprehenderit, excepturi soluta, cumque sed maiores in doloremque assumenda? Eum, officia? Praesentium aspernatur neque atque numquam iste.</p> </div> <div class="phases-col"> <img class="phases1" src="/images/1645176961476.png" /> <h3>Phase3</h3> <p>Lorem ipsum, dolor sit amet consectetur adipisicing elt. Repellendus, minus eius earum necessitatibus reprehenderit, excepturi soluta, cumque sed maiores in doloremque assumenda? Eum, officia? Praesentium aspernatur neque atque numquam iste.</p> </div> </div> </div> </section>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

esta es la respuesta que he encontrado que parece funcionar bastante bien:

 window.addEventListener("scroll", function(event){ var scroll = this.scrollY; if (scroll > 190) { document.getElementById('phases2').style.backgroundColor = "rgba(5, 5, 5, 0.548)" } else { document.getElementById('phases2').style.backgroundColor = "" } if (scroll > 650){ document.getElementById('phases2').style.backgroundColor = "", document.getElementById('phases3').style.backgroundColor = "rgba(5, 5, 5, 0.548)" }else { document.getElementById('phases3').style.backgroundColor = "" } if (scroll > 960){ document.getElementById('phases3').style.backgroundColor = "", document.getElementById('phases4').style.backgroundColor = "rgba(5, 5, 5, 0.548)" }else { document.getElementById('phases4').style.backgroundColor = "" } })
about 4 years ago · Juan Pablo Isaza Report
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!