Business
Jobs
  • About Us
  • Solutions
    • Candidates
      Highly qualified candidates in 48h.
    • Assessments
      500+ technical and psychological assessments, plus anti-fraud system.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Pay in 15+ LATAM countries without setting up a local entity.
  • Pricing
  • Jobs

0

208
Views
La alineación de texto no funciona cuando se obtiene texto del atributo de datos en la etiqueta del objeto

Entonces mi código html tiene una estructura como esta.

 <div className="App"> <header className="App-header"> <Container fileType={this.state.currentFileType} file= this.state.currentFile} /> <Board handleClick={() => this.handleClick()} /> </header> </div>

y este es mi contenedor div que contiene el texto. Los datos simplemente llaman a un archivo .txt básico de dos oraciones.

 <div className="NoteContainer"> <object data={"/Notes/" + props.file} /> </div>

Mi css se ve así

 .App{ text-align: center; background-color: #a461f2; } .App-header { height: 100vh; width: 100vw; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(10px + 2vmin); color: white; } .NoteContainer { padding:40px; display: flex; text-align: center; }

Por alguna razón, no puedo obtener el texto que viene de note1.txt al centro. Cualquier ayuda sería muy apreciada.

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

0

text-align es para Texto. puedes probar:

 align-items: center; justify-content: center; align-content: center;
about 4 years ago · Juan Pablo Isaza Report

0

Entonces, después de mucho investigar, no encontré ninguna manera fácil de centrar el texto, así que lo que terminé haciendo es esto >>>

Hice un script para convertir el simple note.txt en un archivo json con un atributo. Asegúrese de usar qoutes individuales alrededor del exterior y doble dentro de jsonString porque para mí no permitía que los encabezados json se envolvieran con qoutes individuales.

 jsonString = '{\n "text" : "' + text[i] + '" \n}'; filename = "note" + (i + 1) + ".json" await writeFile(dirToWrite + filename, jsonString);

Luego pasé filePath al componente secundario y usé fetch para obtener el texto

 try { const text = await fetch(filePath) .then((r) => r.json()) return text; } catch (err) console.log(err); return "Error"; }

De esta manera, puedo pasar texto como el valor del archivo y se aplicarán los atributos css regulares. Espero que esto ayude a cualquiera que haya tenido el mismo problema que yo.

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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!