在给元素指定最大宽度后,增加样式:
//单行省略号
white-space: nowrap;
overflow: hidden;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
//多行省略号
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
如果在table中td内容超过想要宽度后,想要隐藏内容并用省略号代替,需要对table增加样式:table-layout:fixed;
table{
table-layout:fixed;
}