我用桌子作日历,我设置了:
td, th {
display: table-cell;
}
可以设置td高度吗?
示例:代码是否可以?
display: table-cell;
height: 25px;
max-height: 25px;
请帮助设置td height。
答案 0 :(得分:2)
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>
&#13;
答案 1 :(得分:0)
使用以下css ..它将满足您的要求
td,th{
height:25px;
}