html - 用长字包裹表格单元格

标签 html css

我试着按照这里的解释:How to wrap table cell at a maximum width in full width table

但我无法制作一些东西来包装我的“xxxxxxxxxxxxx”行。

<table class="my-list table table-bordered table-hover">
    <tbody>
        <tr>
            <th>User id</th>
            <th>User name</th>
            <th>Type</th>
            <th>Id</th>
            <th>Ad content</th>
            <th>Created at</th>
        </tr>
        <tr>
            <td>66666</td>
            <td>John Smith</td>
            <td>type1</td>
            <td>99999</td>
            <td>
                <div>
                    Good content with words and real sentences.
                </div>
            </td>
            <td>2015-09-02</td>
        </tr>
        <tr>
            <td>777777</td>
            <td>Martin  Isabelle</td>
            <td>type2</td>
            <td>888888</td>
            <td>
                <div>
                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                </div>
            </td>
            <td>2015-09-02</td>
        </tr>
    </tbody>
</table>

https://jsfiddle.net/jfmqgh20/2/

最佳答案

updated link

CSS 代码:

table {
    width: 100%;
}
td {
    text-align: right;
    white-space: nowrap;
}
td div {
    white-space: normal;
    word-break: break-all;
    display: block;
}

关于html - 用长字包裹表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32778339/

相关文章:

html - 为什么 LI 不扩展内容

javascript - 使用html :not when element has multiple classes

html - 如何将所有星级放在同一行?

javascript - 居中不是div中的所有内容

html - 给列表编号的正确方法是什么?

javascript - 无法修改滚动速度

javascript - react JSX : Maximum update depth exceeded

javascript - 使用 window.location.href 丢失时间顺序

javascript - JS/Angular - 如何在网页上分离多个框的加载微调器

html - 谷歌浏览器中的 div float 左错误