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

246
Views
is there a way to iterate through array, listing each item in fixed-height container until all available space taken?

Using Vue, I have a div container with fixed height, overflow: hidden, I want to iterate through javascript array, adding each item to the div, and stop when the bottom of the div space is reached. Would also need it to be responsive.

<div class="container">
  <div class="header">Header</div>
  <div class="body" v-for="item in items">
    <div>{{ item.data }}</div>
  </div>
  <div class="footer">Footer</div>
</div>

.container {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.header {
  height: 100px;
}

.footer {
  height: 100px;
}

.body {
  flex: 1;
  overflow: hidden;
}

Maybe you would need to retrieve the height of the container in pixels and divide by font height of your item.data perhaps? In any case the number of items displayed would need to change whenever window is resized in order to make it responsive.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. You could do it like you are doing it, and use element.offsetHeight to know when you've gone too far
  2. You could set CSS property max-height to set a max height (you might also want to set the overflow-y property)
  3. You could use a SELECT and set the size attribute on that
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!