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

271
Vistas
How to implement text-overflow: ellipsis with JavaScript?

In CSS it is easy to truncate text with ... at the end.

.elem {
  width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

Unfortunately I can't use text-overflow: ellipsis in CSS because Safari shows a browser-native tooltip whenever text-overflow: ellipsis is applied and I want to show my own custom tooltip.

I know I can detect if the text is overflowing with:

elem.scrollWidth > elem.getBoundingClientRect().width

What to do from there I can't comprehend. How do I determine which characters are within view so I can grab the last three characters and turn them into full stop dots?

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