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

112
Views
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 answers
Answer question

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 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!