Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table row not expanding to full width

I have a table and when I set the table to a width of 100% and the table rows to a width pf 100% nothing happens or changes to the width.

.Table-Normal {      position: relative;      display: block;      margin: 10px auto;      padding: 0;      width: 100%;      height: auto;      border-collapse: collapse;      text-align: center;  }    .Table-Normal thead tr {      background-color: #E74C3C;      font-weight: bold;  }    .Table-Normal tr {      margin: 0;      padding: 0;      border: 0;      border: 1px solid #999;      width: 100%;  }    .Table-Normal tr td {      margin: 0;      padding: 4px 8px;      border: 0;      border: 1px solid #999;  }    .Table-Normal tbody tr:nth-child(2) {      background-color: #EEE;  }
<table id="top-leader" class="Table-Normal">      <thead>          <tr>              <td>Position</td>              <td>Name</td>              <td>Kills</td>              <td>Deaths</td>          </tr>      </thead>      <tbody>          <tr>              <td>1</td>              <td>John Doe</td>              <td>16 Kills</td>              <td>0 Deaths</td>          </tr>            <tr>              <td>2</td>              <td>John Smith</td>              <td>13 Kils</td>              <td>1 Death</td>          </tr>            <tr>              <td>3</td>              <td>Bob Smith</td>              <td>11 Kills</td>              <td>0 Deaths</td>          </tr>      </tbody>  </table>
like image 528
Moussa Harajli Avatar asked Feb 12 '14 00:02

Moussa Harajli


People also ask

How do I increase the width of a row in a table?

To adjust column width automatically, click AutoFit Contents. To adjust table width automatically, click AutoFit Window.

How do you make a full width occupy table?

You need to set the margin of the body to 0 for the table to stretch the full width. Alternatively, you can set the margin of the table to a negative number as well.

How do you fix the width of a table in HTML?

To set the table width in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property width.


2 Answers

Remove display: block in .Table-Normal

Fiddle

.Table-Normal {     position: relative;     //display: block;     margin: 10px auto;     padding: 0;     width: 100%;     height: auto;     border-collapse: collapse;     text-align: center; } 
like image 125
JunM Avatar answered Sep 24 '22 03:09

JunM


By specifying display: block you've overriding the default value from the browser stylesheet for the table element: display: table. Removing display: block or replacing it with display: table fixes this.

like image 27
gsnedders Avatar answered Sep 22 '22 03:09

gsnedders