我試圖做一件很簡單的事情:將tr
的高度設置爲0px
,但它不起作用。tr/td高度拒絕爲0
請參閱我的試用碼或this JSFiddle。
HTML:
<table>
<tbody>
<tr>
<td>
Title 1
</td>
<td>
Title 2
</td>
</tr>
<tr class="model">
<td>
<input placeholder="Name">
</td>
<td>
<input class="delete" type="checkbox">
</td>
</tr>
</table>
CSS:
.model, .model * {
max-height: 0 !important;
min-height: 0 !important;
height: 0 !important;
margin-top: 0 !important;
margin-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
border-top: 0 !important;
border-bottom: 0 !important;
outline: 0 !important;
}
.model {
background-color: red;
}
結果:
有一個在結果紅,所以tr
高度依然不爲0
如何在保持寬度的同時將其設爲0,?
編輯:問題似乎是checkbox
嵌套到td
。我怎麼能得到其高度降至0?
爲什麼你想讓0高度的TR?或者只是想讓這些輸入字段對用戶隱藏? – FrozenFire
@FrozenFire爲什麼在600個字符中有點難以解釋,但我可以說我需要'tr'高度爲0,而不僅僅是輸入。 – Quelklef
您可以將這些輸入放在標題1或2下,然後隱藏它。 – FrozenFire