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

207
Visualizações
html table data not filling columns

I have a html table, I am toggling the table in and out of view by connecting a button to the following script:

function show() {
if (document.getElementById("displaytable2").style.display === "none") {
  document.getElementById("displaytable2").style.display = "inline-block";
} else {
  document.getElementById("displaytable2").style.display = "none";
}
}

I am using ‘get skeleton’ as a boiler plate for the table. The in ‘get skeleton’ there is a class that takes 12 columns. It spreads the table over 12 columns. When I load the html the table is spread out over 12 rows (as desired). However when I click the button to hide the table, and re-click to show the table the table is no longer occupying 12 columns.

The 12 columns are occupied by the table but the only 3 of the columns of the 12 show the data.

My table:

 <div class="row">
       <table class="eleven columns" id="displaytable2" border="1px">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>
    </div>

What’s the story there, how can that be fixed. its as if the data is only filling in the amount of columns that it has, instead of spreading the data out over all the columns.

before clicking: enter image description here

after clicking re-click:

enter image description here

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

0

The columns and eleven classes you've used on your table correspond to grid columns not table columns. They should go on a div.

There's a class to make the table full width of the grid and it's called u-full-width.

Your HTML should look like this:

<div class="row">
   <div class="eleven columns">
      <table class="u-full-width" id="displaytable2" border="1px">
         <tr>
            <th>Company</th>
            <th>Contact</th>
            <th>Country</th>
         </tr>
         <tr>
            <td>Alfreds Futterkiste</td>
            <td>Maria Anders</td>
            <td>Germany</td>
         </tr>
         <tr>
            <td>Centro comercial Moctezuma</td>
            <td>Francisco Chang</td>
            <td>Mexico</td>
         </tr>
      </table>
    </div>
</div>

The first div creates a row, typically full length of the parent container.

The second div spits the row into columns, where the eleven class specifies that it's 11 columns inside a row (possible maximum is twelve).

The table class, u-full-width will let the table know to take up all the available columns - in this case all 11.


Besides the point here, I also notice that you set the table to be a block afterwards which is causing the table to "shrink".

You should be using: document.getElementById("displaytable2").style.display = "table"; To give the table behaviour back.

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