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

134
Views
how to make a generated table scale to a div height

I'm trying to scale a js generated table to a div's height and width. I've tried some solutions online but none worked for me. (the table is x*x depends on user input)

so far I've only mannaged to scale the table on width but not the height.

this is what I did:

div
{
    max-width: 70vw;
    max-height: 90vh;   
    overflow-x: auto;
}
td {
    
    width: 200px;
    height: 200px;
    
    border-radius: 20px;
    background-color: #d5bbee;
}
table{
   
    width: 100%;
    height: 100%;
    
    border-radius: 20px; 
    border-spacing: 15px;
    border-collapse:separate;
    background-color:rgb(102, 184, 211) ;
    border-color: transparent;
}
<div>
  <table>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </table>
</div>

the width of every cell is somehow scaled to fit the width of the table, but the height of every cell is still 200px so it acts diffrently. Iv'e tried table-layout:fixed and overflow:hidden but nothing have the same affect on the height. I do want the table to only scale if it's going to become larger than the div.

thanks for any help :]

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

0

You need to set parent div height. Currently, it will expend only if necessary.

div
{
    max-width: 70vw;
    max-height: 90vh;
    height: 90vh; 
    overflow-x: auto;
}
td {
    
    width: 200px;
    
    border-radius: 20px;
    background-color: #d5bbee;
}
table{
   
    width: 100%;
    min-height: 100%;
    
    border-radius: 20px; 
    border-spacing: 15px;
    border-collapse:separate;
    background-color:rgb(102, 184, 211) ;
    border-color: transparent;
}
<div>
  <table>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </table>
</div>

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!