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

234
Views
No se pueden obtener las coordenadas del elemento html

Traté de obtener las coordenadas del Bloque-1 y desplacé la página hacia él, pero hice algo mal =( ¿Cómo obtener las coordenadas html del elemento del Bloque-1 y desplazar la página hacia él?

 let elem = document.querySelector('.Block-1'); let coords = elem.getBoundingClientRect(); elem.style.top = coords.bottom + 'px'; window.scrollTo({ top: elem, behavior: "smooth" });
 .Block-1 { margin-top: 500px; border: 1px solid black; font-size: 30px; padding: 50px; }
 <div class="Block-1"> Scroll here </div>

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Usted estaba en el camino correcto. La propiedad superior de scrollTo() es la propiedad superior de getBoundingClientRect() . Entonces, top: coords.top .

 let elem = document.querySelector('.Block-1:nth-child(2)'); let coords = elem.getBoundingClientRect(); window.scrollTo({ top: coords.top, behavior: "smooth" });
 .Block-1 { margin-top: 500px; border: 1px solid black; font-size: 30px; padding: 50px; }
 <div class="Block-1"> Not here </div> <div class="Block-1"> Scroll here </div> <div class="Block-1"> Not here </div>

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