Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
How to keep the content of a span together when resizing window (how to "word-break" at span boundaries)?

In my case, &nbsp doesn't work. I have a span containing a react icon and a number next to it on the right side (think a star icon and a user rating). When I resize my viewport to a certain breakpoint, the number on the right shifts down to a new line, but the icon stays in place. I'd like to make it so that if there isn't enough space for the icon and number to be displayed together on that line, then they both move down to a new line, so that the icon and number are never broken apart.

The code looks something like:

  <p className={styles["key-info"]}>
    <span>
      {release ? release.substring(0, 4) : "Unknown Release Date"}
    </span>
    <span> &#183; {rating}</span>
    <span> &#183; {formatMinutes(runtime)}</span>
    <span>
      {" "}
      &#183; <FaStar className={styles["star-icon"]} />
      {score}
    </span>
  </p>

How do I ensure that my spans are kept together when resizing the window and in particular in the case of the last span, how do I prevent the number on the right (score) from hopping to a new line without the icon, and then the icon hopping down when the window is resized even further? I read somewhere that   should work, but it doesn't.

Hope what I'm asking is pretty clear. If not, I'd be happy to clarify. I should also mention that the thing which is causing the content to break to a new line is the container shrinking. Maybe that's relevant.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try putting them under one div

<div class="together">
<FaStar className={styles["star-icon"]} />
      {score}
</div>

and then set the

white-space:nowrap;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda