Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda