-1

I have some problems with wrong calculating of cell's position and width.

Summary, problem:

Width of left column is increasing too fast(while inside text is writing), so that steal the space of right column, really important spase.

My code:

table {
  width: 100%;
}

td {
  border: 1px solid black;
}
<table>
  <tr>
    <td>This</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too much</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too much space</td>
    <td>1</td>
  </tr>
</table>
James Coyle
  • 9,019
  • 1
  • 33
  • 47
Egor
  • 217
  • 4
  • 18

2 Answers2

1

table {
  width: 100%;
}
td:first-child {
  border: 1px solid black;
  white-space: nowrap;
}
td:last-child {
  border: 1px solid black;
  width: 100%;
}
<table>
  <tr>
    <td>This</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
   <td>This text escapes too much</td>
   <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too much space</td>
    <td>1</td>
  </tr>
</table>
Nicolae Maties
  • 2,214
  • 1
  • 11
  • 22
0

Is this what you are looking for?

table {
  width: 100%;
}
td {
  border: 1px solid black;
  white-space: nowrap;
}
td:nth-child(2){
  width: 100%;
}
<table>
  <tr>
    <td>This</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too</td>
    <td>1</td>
  </tr>
</table>
<table>
  <tr>
   <td>This text escapes too much</td>
   <td>1</td>
  </tr>
</table>
<table>
  <tr>
    <td>This text escapes too much space</td>
    <td>1</td>
  </tr>
</table>
halfer
  • 19,471
  • 17
  • 87
  • 173
Paddy Hallihan
  • 1,550
  • 3
  • 24
  • 56