效果如图
代码:
<style>
table td{white-space:nowrap;overflow:hidden; text-overflow:ellipsis;}
table {table-layout:fixed;}
</style>注意!给TD指定宽度(否则宽度自动分配,达不到理想的效果).
本文介绍了一种使用CSS样式使表格单元格内的文本在超出指定宽度时进行省略显示的方法。通过设置`white-space:nowrap;overflow:hidden;text-overflow:ellipsis;`样式属性,并固定表格布局,可以有效地控制表格单元格中的文本显示,使其不会因内容过长而影响整体布局。
效果如图
代码:
<style>
table td{white-space:nowrap;overflow:hidden; text-overflow:ellipsis;}
table {table-layout:fixed;}
</style>注意!给TD指定宽度(否则宽度自动分配,达不到理想的效果).
15万+
2万+

被折叠的 条评论
为什么被折叠?