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

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

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