如何强制限制表格宽度

快享 2010-04-14 09:14:05 累计浏览 3,110 次

网站有个地方由于个别用户写的域名比较长,导致表格被撑的很开这就需要强制限制表格宽度(防止文字对列表的挤开),举个例子如下:

<table>

    <tr>
      <td width="5%" >模版ID</td>
      <td width="10%" >模版组</td>
      <td width="20%"  >短信内容</td>
      <td width="15%" >发送范围</td>
      <td width="8%" >添加人</td>
      <td width="12%" >更新时间</td>
      <td width="8%" >有效期</td>
      <td width="12%" >备注</td>
      <td width="10%" >操作</td>
    </tr>
    <s:iterator value="result" id="beans">
      <tr onClick="ClickEvent(this)" onMouseDown="this.className='tblSubDeepBlue'" onMouseOver="overEvent(this)"  onMouseOut="OutEvent(this)" id="${tempId}">
        <td style="word-break:break-all;text-align:left;">${tempId}</td>
        <td style="word-break:break-all;text-align:left;"  >${smsTemplateGroup.groupName}</td>
        <td style="word-break:break-all;text-align:left;">${smsContent}</td>
        <td style="word-break:break-all;text-align:left;">${sendScope}</td><!--这里的样式是为了强制限制列表宽度,不让文字把列宽挤开, 让上面的width="15%"真正起到作用-->        <td style="word-break:break-all;text-align:left;">${operator}</td>
        <td ><s:date name="updateTime" format="yyyy-MM-dd HH:mm" /></td>
        <td ><s:date name="endTimes" format="yyyy-MM-dd" /></td>
        <td style="word-break:break-all;text-align:left;">${remarks}</td>
        <td><a href="javascript:void(0);" onClick="modify('${tempId}')">修改</a>
         <a href="javascript:void(0);" onClick="doRemove('${tempId}')">删除</a> </td>
      </tr>
    </s:iterator>
    <tr>
      <td colspan="9"><%@include file="/common/simplePager.jsp"%></td>
    </tr>

</table>

同分类推荐文章

  1. Embracing Playful Imperfection With The CSS `random()` Function (2026-11-14 03:10:02)
  2. Document Picture-in-Picture API与任意元素画中画实现 (2026-11-13 17:10:02)
  3. 给博客做个站内全文搜索:纯前端离线倒排索引的设计与取舍 (2026-10-03 16:40:31)

查看更多 前端 文章 →

建议继续学习

  1. 50个活力和动感的网页设计-颜色的灵感 (累计阅读 34,823)
  2. 视觉设计前瞻实用性研究(PNVD) 第二期 (累计阅读 13,328)
  3. 各公司对前端开发的职位描述 (累计阅读 10,731)
  4. iframe大小自适应 (累计阅读 10,393)
  5. 浏览器的渲染原理简介 (累计阅读 8,820)
  6. 解决IE6从Nginx服务器下载图片不Cache的Bug (累计阅读 8,800)
  7. iframe里src="about:blank"的问题。 (累计阅读 8,546)
  8. 程序员眼里IE浏览器是什么样的 (累计阅读 8,316)
  9. 2010网页设计趋势 (累计阅读 8,129)
  10. Web前端工程师编程能力飞升之路 (累计阅读 8,042)