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

213
Visualizações
How do i make a html table not have dynamic columns that change size in width depending on the amount of data in a <td>

I am trying to create a table that has equally sized columns which wont change depending on the length of the table data

enter image description here

In the picture the data under the heading "Titel" moves the second column further to the right compared to the other tables where "Titel" is shorter. This behaviour is not wanted but it seems to be the default.

I tried padding the first column but it doesn't change the behaviour at all. How can i achive a fixed size that doesnt push other columns away?

Here is an example code which gives the unwanted behaviour

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  padding: 5px;
}
table {
  border-spacing: 15px;
}

    </style>
    </head>
    <body>
    
    <h2>Border Spacing</h2>
    <p>Border spacing specifies the space between the cells.</p>
    
    <table style="width:100%">
      <tr>
        <th>Firstname</th>
        <th>Lastname</th> 
        <th>Age</th>
      </tr>
      <tr>
        <td>Jill</td>
        <td>Smith</td>
        <td>50</td>
      </tr>
      <tr>
        <td>Eve</td>
        <td>Jackson</td>
        <td>94</td>
      </tr>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>80</td>
      </tr>
    </table>
    
    </body>
    </html>

I've tried setting width on the table and its columns, and also padding the table but it doesn't work.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

With Bootstrap 4.0 you can use the sizing utilities classes for widths:

<thead>
     <tr>
           <th class="w-25">25</th>
           <th class="w-50">50</th>
           <th class="w-25">25</th>
     </tr>
</thead>

You can also use d-inline-block to prevent the default setting of display:flex.

about 4 years ago · Juan Pablo Isaza Relatório

0

I solved it by using style="table-layout:fixed" on the table and using bootstrap cols on the table headers.

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