如何设置 table 单元格 "display: table-cell" 的高度

How to set height of table cell "display: table-cell"

日历我用了table,我设置了:

td, th {
    display: table-cell;
}

可以设置 td 高度吗?

示例:下面的代码是否可行?

display: table-cell;
height: 25px;
max-height: 25px;

请帮忙设置td高度

使用以下 css..它将满足您的要求

td,th{ 
height:25px; 
}

table 已经是 display: table-cell;(默认)


不过你可以设置height

table {
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

td, th {
    display: table-cell;
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;
    height: 25px;
}

tr:nth-child(even) {
    background-color: #dddddd;
}
<table>
  <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>
  <tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
  </tr>
  <tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
  </tr>
  <tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
  </tr>
  <tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
  </tr>
</table>