css - Using calc() in table -


this question has answer here:

i trying use calc fix width of th:last-child differs others 15px. i've done is:

th:last-child {     width: calc( (100% - 30px)/12 + 30px );  }  table, tr {  width:100%;  border: 1px solid black;  height:10px;  }  th {    border-right: 1px solid black;    width: calc( (100% - 30px)/12 );  }
<table>  <thead>    <tr>      <th>column 1</th>      <th>column 2</th>      <th>column 3</th>      <th>column 4</th>      <th>column 5</th>      <th>column 6</th>      <th>column 7</th>      <th>column 8</th>      <th>column 9</th>      <th>column 10</th>      <th>column 11</th>      <th>column 12</th>    </tr>  </thead>  <tbody>   <tr>      <td>row 1</td>      <td>row 2</td>      <td>row 3</td>      <td>row 4</td>      <td>row 5</td>      <td>row 6</td>      <td>row 7</td>      <td>row 8</td>      <td>row 9</td>      <td>row 10</td>      <td>row 11</td>      <td>row 12</td>   </tr>       </tbody>   </table>

js fiddle reproduction.

i've divided 12 because number of columns in table. understood 100% treated width of parent. problem finally, don't expect, idea why?

you must set table-layout property 'fixed'.

see using calc() tables

and working example: https://jsfiddle.net/rpyydd5n/3/


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -