html - 使用 CSS 在特定宽度内安装损坏的 html 表格

标签 html css width html-table

我有以下损坏的 html,我无法真正编辑,也最好使用 javascript 进行修改,我试图使其适合 x 宽度:http://jsfiddle.net/P7A9m/2/

<div id="main">
    <table>
        <tr>
            <td>
                test
                test
                longWooooooooooooooooooooooooooooooooooooooooord
                test
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
        </tr>
    </table>
</div>

(我知道存在不匹配的数量,但如果第一个 tr 有 2 td,问题将是相同的。)

现在,我不能使用“table-layout: fixed;”并将表格设置为与父 div 相同的宽度,因为它会使内容仅使用可用空间的 50%。 有什么方法可以做我想做的事吗?

最佳答案

我认为你需要 css 属性:

word-break: break-all;

关于html - 使用 CSS 在特定宽度内安装损坏的 html 表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20500016/

相关文章:

javascript - 更改与其 slideDown 和 slideUp 状态相关的导航栏颜色

html - 将图像定位在 div 的顶行

html - 内联列表被悬停效果破坏

javascript - EXTJS 4.1 中的向上组合框

css - 需要使 css 网格列比其他列更窄吗?

jquery - 计算所有列表项的总宽度?

CSS:如何在宽度为 100% 的情况下并排 float 3 个 div 而不会弄乱?

javascript - 如何将 HTML 表单链接到 JavaScript 中的函数?

html - 条形码不出现在打印预览中,但出现在 HTML 页面上

javascript - 移动菜单打开时 body 的滚动锁定不起作用