CSS文本-表格單元格中的溢出?我想使用CSStext-overflow在表格單元格中,如果文本太長(zhǎng),不能放在一行上,它將用省略號(hào)剪輯,而不是包裝到多行。這個(gè)是可能的嗎?我試過(guò)這個(gè):td {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;}但white-space: nowrap似乎使文本(及其單元格)不斷向右展開(kāi),將表的總寬度推到容器的寬度之外。但是,如果沒(méi)有它,當(dāng)文本到達(dá)單元格的邊緣時(shí),將繼續(xù)換行到多行。
3 回答

慕姐4208626
TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超7個(gè)贊
max-width
td
td { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
max-width
max-width: 0;
width: 100%;
table { width: 100%;}td { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}td.columnA { width: 30%;}td.columnB { width: 70%;}
<!--[if IE]> <style> table { table-layout: fixed; width: 100px; } </style> <![endif]-->
添加回答
舉報(bào)
0/150
提交
取消