我應該在這里有一個非常簡單的問題。我有一個表格,想將每個單元格的行高設定為 8%。我也啟用了斷字。如果頁面寬度減小,文本會重疊(因為我明確設定了行高)。見代碼實作:
table, th, td {
font-size: 12px;
font-weight: 450;
word-break: break-word;
line-height: 8%;
margin-bottom: 8%;
}
例子:

如您所見,文本重疊。雖然我想明確分配行高,但我也希望如果文本移動到兩行,單元格會增長。正如您在 css 檔案中看到的,我嘗試使用 margin-bottom 但沒有運氣。任何建議表示贊賞。提前致謝!
這解決了我的問題:
tr, th, td {
font-weight: 450;
font-size: 11px;
word-break: break-word;
line-height: 90%;
}
uj5u.com熱心網友回復:
line-height: 8%;表示 該元素字體大小的8% ,這就是導致所描述的重疊的原因。
嘗試使用“110%”或“1.1”(等于 110%)之類的值,并嘗試根據需要在瀏覽器工具中調整該值,直到找到符合您期望的值。
此外,我只會將其應用于td,并且margin僅適用于table. 如果您需要單元格內部的空間,請使用padding它們。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/381205.html
標籤:html css html-table
