首先需要在table中设置table-layout:fixed;

<table style="table-layout:fixed"></table>

然后在表头th中设置每列的宽度

<table style="table-layout:fixed">
<th width="10%">Title01</th>
<th width="20%">Title02</th>
<!--  其他th -->
</table>

然后在需要当长度大于一定数值时用省略号表示的td上面添加样式

<table style="table-layout:fixed">
<th width="10%">Title01</th>
<th width="20%">Title02</th>
<!--  其他th -->
<c:foreach items = ""  var ="" varStatus = "">
<td><title01</td>
<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"><title02</td>
<!--  other td   -->
</c:foreach>
</table>

bootstrap在设置表格大小时需要设置到th中,否则可能不会生效,以上在bootstrap中可用

当不使用bootstrap的时候可以使用如下样式,网上搜索到的,比较好用

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <style type="text/css">
.mytable {
   table-layout: fixed;
   width: % border:0px;
   margin: 0px;
}   

.mytable tr td {
    text-overflow: ellipsis; /* for IE */
    -moz-text-overflow: ellipsis; /* for Firefox,mozilla */
    overflow: hidden;
    white-space: nowrap;
    border: 1px solid;
    text-align: left
}
</style>
</head>
<body>
    <table width="500px" class="mytable">
        <tr>
            <td width="20%">再别康桥</td>
            <td width="80%">
                轻轻我走了,正如我轻轻地来,我挥一挥衣袖,不带走一片云彩
            </td>  

        </tr>
    </table>
</body>
</html>  

最新文章

  1. CentOS下yum安装LAMP
  2. JAVA 8 方法引用 - Method References
  3. 深入理解计算机系统(2.7)---二进制浮点数,IEEE标准(重要)
  4. Unity3D中Console控制台的扩展
  5. DOTween文档
  6. Java正确转换html编码
  7. 【技术贴】解决bug mantisbt APPLICATION ERROR #1502 没有找到类别
  8. Percona-Galera-Monitoring-Template监控模板说明
  9. 【每天一个Linux命令】10. 用户账号的新建/修改/删除以及密码修改 useradd/usemod/userdel/passwd
  10. 关于hover没有效果的问题
  11. jBPM5 vs Actitivi
  12. android 中Log - 简单使用
  13. Java中的static关键字
  14. 虎说:bootstrap源码解读(重置模块)
  15. mysql 时间戳格式化函数FROM_UNIXTIME和UNIX_TIMESTAMP函数的使用说明
  16. Shell读取配置文件的方法
  17. sleep、wait、notify、notifyAll的区别
  18. VM12中CentOS7以NAT方式连接网络的方法
  19. maven 将jar包推送到自己本机的maven库
  20. js的快速搜索

热门文章

  1. hdu 1069 Monkey and Banana
  2. 在caffe中添加新的layer
  3. 【JAVA】数字相加
  4. Netty 入门示例
  5. css 让内容满屏居中不变形
  6. hdu1963 完全背包(数据压缩)
  7. 2016.9.13 JavaScript入门之六基础函数
  8. css整理-04 基本视觉格式化
  9. JavaScript 笔记 ( Prototype )
  10. 持续集成基础-Jenkins(二)-搭建Jenkins环境和配置第一个Job