I need to set the fixed height of the cells in the first row of the table (say, 45px ). After that, it is necessary to center the values ​​inside the cells: both horizontally and vertically.

Here is the first row of the table:

 .text-center > th { text-align: center; vertical-align: middle; } 
 <tr class="font-size-12 text-center"> <th>№</th> <th>Период</th> <th>Исходные значения</th> <th>Модельные значения</th> </tr> 

But I do not understand where to set the height of the cell. If in any of th , then vertical centering does not work and it turns out like this:

screen

  • Do you use bootstrap ? - Shnur

2 answers 2

Should work.

https://codepen.io/laser_beard/pen/bRrYRr

You probably have some other css effect on it. Look in the line-height , vertical-align , display , padding inspector for th . Maybe something overlaps

    The specification says that the <th> used in two columnar tables, and judging by the screenshot you have more of them, you presented only part of the code and there is no clarity from here, try changing <th> to <td> Or, alternatively, for <th> specify not vertical-align but valign with middle value. By the way, keep in mind that <th> not supported in HTML5