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

242
Views
¿Cómo envolver el texto escrito con 'typed.js' ReactJs?

Estoy creando una aplicación web con React que genera citas aleatorias de películas... Aquí hay una vista previa de la aplicación web.

El problema surge cuando la cita es demasiado larga y se desborda fuera del div principal... Intenté alterar el css con display flex y flex-wrap configurado para envolver. no funciona Aquí está mi código.

 import React from 'react'; import Typed from 'typed.js'; import './App.css'; import quotes from './quotes.json'; const random_quote = () => { const rand = Math.floor(Math.random() * quotes.length); let selected_quote = quotes[rand].quote + ' - ' + quotes[rand].movie; return selected_quote; } const TypedQuote = () => { // Create reference to store the DOM element containing the animation const el = React.useRef(null); // Create reference to store the Typed instance itself const typed = React.useRef(null); React.useEffect(() => { const options = { strings: [ random_quote(), ], typeSpeed: 30, backSpeed: 50, }; // elRef refers to the <span> rendered below typed.current = new Typed(el.current, options); return () => { // Make sure to destroy Typed instance during cleanup // to prevent memory leaks typed.current.destroy(); } }, []) return ( <div className="type-wrap"> <span style={{ whiteSpace: 'pre' }} ref={el} /> </div> ); } const App = () => { return ( <> <div className='background' id='background'> <div className='quote-box'> <TypedQuote /> </div> <button onClick={random_quote}>New Quote</button> </div> </> ); } export default App;

Tengo esta idea donde podría implementar una función que agregue '\n' después de 10 palabras o tal vez después de un '.' o ',' (podría implementar algo de lógica aquí). Pero esto parece una posibilidad remota. ¿Hay una manera más elegante de hacer esto? Cualquier ayuda sería apreciada.

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

0

Pruebe la propiedad a continuación en el contenedor principal.

 word-wrap: break-word;

o el de abajo si quieres dividir las palabras también

 word-break: break-all;
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!