如何实现网页表格中一行多出的文字变成省略号或者隐藏

如题所述

实现代码如下:
.mytable{
width:500em;
table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */
}
.mytable td{
width:100%;
word-break:keep-all;/* 不换行 */
white-space:nowrap;/* 不换行 */
overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一 起使用。*/
}

采用 css 样式 来隐藏
<style type="text/css">
.style1{
overflow: hidden;
white-space:nowrap;
text-overflow: ellipsis;
width:200px;
}
</style>
一般添加到<head>之间即可。
温馨提示:答案为网友推荐,仅供参考
相似回答