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

191
Views
Tabla de centrado creada usando un mapa de matriz en la aplicación web de reacción

He construido una tabla usando la función array.map en reaccionar. Por alguna razón (incluso antes de la tabla), la salida de array.map siempre está alineada a la izquierda. Me gustaría centrar toda la mesa.

JSX:

 <div className="center"> <table className="center" style={{border:'solid',}}> <thead className="has-text-black-bis" style={{backgroundColor:"#e6be8a"}}> <tr> <th >Product Name:</th> <th >Unit Price:</th> <th >Quantity Available:</th> <th >Buy!</th> </tr> </thead> <tbody className="has-text-black-bis"> {this.state.indices.map((a) => ( <tr className="rows"> <td ><strong>{this.state.itemNames[a]}</strong></td> <td ><strong>{this.state.costs[a]}</strong></td> <td ><strong>{this.state.quantities[a]}</strong></td> <td > <button type="button" className='create-btn' onClick={()=>this.buyItem(a)}>Buy!</button> </td> </tr> ))} </tbody> </table> </div>

CSS:

 .center { align-self:center; justify-content: center; align-items: center; align-content: center; text-align: center; }

Probé todos los códigos css anteriores y más, intenté poner la tabla en una columna de bulma y centrarla, etc. Puedo centrarla usando márgenes, pero me preocupa que pueda causar errores en pantallas de diferentes tamaños, también tengo la configuración centrada pantalla para flexionar pero eso arruinó el contenido de la tabla.

¡Gracias por cualquier ayuda!

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Modifica tu css con esto. Di el 100% de width y height , pero depende de su solicitud de diseño, puede cambiarlo

 .center { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
about 4 years ago · Santiago Trujillo Report

0

Actualizado:

Simplemente agregue align="center" text-align: center; a la clase de fila de la tabla.

me gusta:

 .rows { text-align: center; } 

 .center { align-self:center; justify-content: center; align-items: center; align-content: center; text-align: center; } .rows { text-align: center; }
 <div className="center"> <table className="center" style={{border:'solid',}}> <thead className="has-text-black-bis" style={{backgroundColor:"#e6be8a"}}> <tr> <th >Product Name:</th> <th >Unit Price:</th> <th >Quantity Available:</th> <th >Buy!</th> </tr> </thead> <tbody className="has-text-black-bis"> <tr class="rows"> <td ><strong>test</strong></td> <td ><strong>test</strong></td> <td ><strong>test</strong></td> <td > </td> </tr> <tr class="rows"> <td ><strong>test</strong></td> <td ><strong>test</strong></td> <td ><strong>test</strong></td> <td > </td> </tr> </tbody> </table> </div>

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