表格单元格宽度 - 固定宽度,换行/截断长字 [英] Table cell widths - fixing width, wrapping/truncating long words

查看:133
本文介绍了表格单元格宽度 - 固定宽度,换行/截断长字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含不同长度文本的单元格的表格。重要的是所有表格单元具有相同的宽度。如果这意味着删除长的单词或强制断言长单词,那就没关系了。

I have a table containing cells with text of various lengths. It is essential that all of the table cells are of the same width. If this means truncating long words or forcing a break in long words then that's OK.

我不知道有什么办法让这个工作。

I cannot figure out any way of getting this to work.

这是一个内部客户端应用程序,因此只需要在IE6和IE7中工作。

This is for an internal client application so needs to work in IE6 and IE7 only.

示例页面如下。包含 onereallylongword 的单元格是违规的。

An example page is below. The cell containing onereallylongword is the offending one.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <style type="text/css">
        td { width: 30px; }
    </style>
</head>
<body>
    <table border="2">
        <tr>
            <td>word</td>
            <td>two words</td>
            <td>onereallylongword</td>
        </tr>
    </table>
</body>
</html>


推荐答案

Stack Overflow解决了类似的问题,代码通过使用DIV并具有 overflow-x:auto 。 CSS不能为你分词。

Stack Overflow has solved a similar problem with long lines of code by using a DIV and having overflow-x:auto. CSS can't break up words for you.

这篇关于表格单元格宽度 - 固定宽度,换行/截断长字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆