3 回答

TA貢獻1942條經驗 獲得超3個贊
現在在HTML5 / CSS3中,我們為該問題提供了更好的解決方案。我認為建議使用這種純CSS解決方案:
table.fixed {table-layout:fixed; width:90px;}/*Setting the table width is important!*/
table.fixed td {overflow:hidden;}/*Hide text outside the cell.*/
table.fixed td:nth-of-type(1) {width:20px;}/*Setting the width of column 1.*/
table.fixed td:nth-of-type(2) {width:30px;}/*Setting the width of column 2.*/
table.fixed td:nth-of-type(3) {width:40px;}/*Setting the width of column 3.*/
<table class="fixed">
<tr>
<td>Veryverylongtext</td>
<td>Actuallythistextismuchlongeeeeeer</td>
<td>We should use spaces tooooooooooooo</td>
</tr>
</table>
您需要width在困擾解決方案中設置表的偶數。否則它將無法正常工作。vsync建議的
另一個CSS3新功能是:。這會將單詞中沒有空格的單詞也分成多行。只需像這樣修改代碼:word-break:break-all;
table.fixed { table-layout:fixed; width:90px; word-break:break-all;}
- 3 回答
- 0 關注
- 375 瀏覽
相關問題推薦
添加回答
舉報