table中td内容过长 省略号显示

首先设置 css样式:

    table { table-layout: fixed;}

HTML中的table代码:

<tr>
<th class="col-md-1">用户ID</th>
<th class="col-md-1">用户名</th>
<th class="col-md-1">联系电话</th>
<th class="col-md-1">邮箱</th>
<th class="col-md-4">描述 </th>
<th class="col-md-2">添加时间</th>
<th class="col-md-2">操作</th>
</tr>
【对于bootstrap应该设置th的固定宽度】

设置td超过固定宽度自动显示为省略号:
table tr td {
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
-moz-text-overflow: ellipsis;
-webkit-text-overflow: ellipsis;
}
posted @ 2017-01-12 17:40  miny_simp  阅读(19457)  评论(0编辑  收藏  举报