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

110
Views
Desplazar un componente de desbordamiento en reaccionar/siguiente

Así que tengo un componente que tiene un ancho fijo con overflow-x-auto. Decidí ocultar la barra de desplazamiento y reemplazarla con 2 flechas/botones tanto a la izquierda como a la derecha. Si hago clic en la izquierda, se desplaza hacia la izquierda y viceversa. ¿Cómo puedo lograr esta funcionalidad?

este es mi componente

 <div className={` vertical-card w-7/12 flex flex-row overflow-x-scroll no-scrollbar pb-4`}> { dataConselor.map((item, index) => { return <VerticalCard key={item.id} name={item.nama} specialist={item.specialist} shortdesc={item.shortdesc} img={item.img} /> }) } </div>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

  1. Apunte al elemento desplazable (puede usar useRef, ya que es reaccionar):
 const scrollable = useRef(null); <div id="myElement" ref={scrollable}> ... </div>
  1. Crear la función de desplazamiento:
 const scrollIt = (toRight) => { const scrollLength = ... //Calculate your scroll length however you want. scrollable.current.scrollBy({left: scrollLength * (toRight ? 1 : -1), behavior: "smooth"}); }
  1. Agregue esta función a los botones izquierdo/derecho:
 <div id="toLeft" onClick={()=>scrollIt(false)}>...</div> <div id="toRight" onClick={()=>scrollIt(true)}>...</div>
about 4 years ago · Juan Pablo Isaza Report

0

Como está utilizando Tailwind CSS, puede usar un componente carousal de Tailwind para lograr este comportamiento.

Hay varios carousals disponibles aquí .

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!