做table表格時,某一列字數比較多,希望超出寬度的部分以省略號顯示
設置table的布局 默認automatic 以表格內容顯示相應寬度 改成fixed 以表格列寬顯示內容
table{
table-layout: fixed;
}
在需要設置列加上
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
white-space:nowrap; 文本以單行顯示,不換行
overflow:hidden; 超出部分隱藏
text-overflow:ellipsis; 超出部分以省略號顯示
如果想讓鼠標放在上邊顯示全部內容,把td里的內容放在div里,加上title屬性
<div style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="${item.REMARK}">${item.REMARK}</div>
div的title屬性和div的內容相同
