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

119
Vistas
How do I get the number of items that will not fit inside the parent dynamically?

I currently have a draggable width container with some children.

all_content_fit

Since its width is draggable once the width is small enough that say for example only 3 elements can fit. Expected outputs are (0), (1), and (+4) (Number of elements that overflow + 1).

3_overflow

Other cases: Here only two elements fit, and 4 overflows. The expected output is two circles with (0) and (+5).

case3_only_2_Fit

I saw other posts where they use a fixed width and calculate the number of elements that can fit from that. However, in my use case, the width is varying and I need to get the number of elements that can fit/overflow dynamically. How can this be done using javascript and plain CSS?

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

0

var popupDiv = document.getElementsById("container")
let count = Math.round(window.getComputedStyle(popupDiv).width/widthOFElement)

I hope this help. here the widthOFElement is the width of round element. and you can add this in dragabble event listener.

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