.flex {
display: flex;
width: 90%;
margin: 0 auto;
justify-content: space-between;
}
table {
width: 48%;
border-collapse: collapse;
}
th, td {
border: 1px solid gray;
padding: 5px;
}
<div class="flex">
<table>
<tbody>
<tr>
<th>1st Table</th>
</tr>
<tr>
<td>
<p>
I want to be <br>
the same height<br>
as the next table
</p>
</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th>2nd Table</th>
</tr>
<tr>
<td>
<p>
This text has 4 lines<br>
This text has 4 lines<br>
This text has 4 lines<br>
This text has 4 lines
</p>
</td>
</tr>
</tbody>
</table>
</div>
我想,以配合無名高地表中最高的表,但我該怎麼辦呢?
在div的情況下,「align-items:stretch」沒有問題。
我試過「align-items:stretch;」,但高度並沒有改變。 如果可能的話,我想通過「td」擴展「th」的高度而不改變它的高度,但是我必須使用JavaScript嗎?
感謝您詳細的解答! 我明白CSS 3中Table標籤的行爲是「不確定的」,它會通過添加一個包裝來「確定地」移動它。 – chatii