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

166
Views
Cadena de salida después de sring.split("").map se rompe en pedazos en pantallas pequeñas

Con gran ayuda de @pratik-wadekar, tengo la siguiente animación de texto de trabajo. Ahora mi problema es que cuando lo pruebo en diferentes tamaños de pantalla/móvil, la palabra animada plants se rompe en pedazos. Por ejemplo PLA y en la siguiente línea NTS. ¿Cómo puedo evitar esto? Así que siempre se mantiene como una palabra completa.

Primero traté de agregar \xC2\xA0 – non-breaking space or   antes y después de la palabra, pero esto no ayuda. La propiedad word-wrap de CSS permite que las palabras largas se puedan romper, pero desafortunadamente para el caso inverso para hacer que una palabra sea irrompible, no hay opción.

Parece que lo que necesito es la propiedad word-break: "keep-all CSS, pero cuando la aplico, todavía se rompe en pedazos en pantallas más pequeñas.

El códec

Y App.tsx :

 import React from "react"; import { styled } from "@mui/material/styles"; import { Typography } from "@mui/material"; const AnimatedTypography = styled(Typography)` & { position: relative; -webkit-box-reflect: below -20px linear-gradient(transparent, rgba(0, 0, 0, 0.2)); font-size: 60px; } & span { color: #fbbf2c; font-family: "Alfa Slab One", sans-serif; position: relative; display: inline-block; text-transform: uppercase; animation: waviy 1s infinite; animation-delay: calc(0.1s * var(--i)); } @keyframes waviy { 0%, 40%, 100% { transform: translateY(0); } 20% { transform: translateY(-20px); } } `; interface Styles extends React.CSSProperties { "--i": number; } function App() { const string = "plants"; return ( <Typography variant={"h3"} fontWeight={"bold"}> All Your <AnimatedTypography> {string.split("").map((char, idx) => { const styles: Styles = { "--i": idx + 1 }; return ( <span key={`${char}-${idx}`} style={styles}> {char} </span> ); })} </AnimatedTypography> in One Place </Typography> ); } export default App;
about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

Bien, lo tengo. Tuve que hacer la animación como un componente propio y agregar <AnimatedTypography> the component={"span"} type and white-space: nowrap . Además de mi const AnimatedTypography = styled(Typography) , tuve que lanzar el componente resultante con un as typeof Typograph y para que Typescript no arroje errores. Ver aquí: Complicaciones con el componente prop

Luego, importé el componente y lo agregué al componente Tipografía entre mi texto. Ahora se conserva el diseño de mi texto y la animación no se divide en caracteres individuales.

about 4 years ago · Santiago Gelvez Report

0

Lo que necesitas es white-space: nowrap .

por favor, compruebe

https://codesandbox.io/s/infalible-matan-rcnclw

about 4 years ago · Santiago Gelvez Report

0

Cada carácter es un <span> separado, por lo que no se analiza como una sola palabra. Una solución sería simplemente hacer que el padre sea un contenedor flex :

 <AnimatedTypography style={{display:"flex"}}>

https://codesandbox.io/s/blissful-sea-4o7498

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!