【问题标题】:Force each row in Bootstrap table to be a one-liner when table is wider than screen当表比屏幕宽时,强制引导表中的每一行为单行
【发布时间】:2014-04-13 04:59:45
【问题描述】:

我正在构建一个动态表,该表由 1-50 列组成,具体取决于用户选择的内容。当用户选择 1-6 列时,在屏幕上显示所有数据没有问题,但是当用户选择超过 6 列时,表格会尝试在屏幕上将视图挤在一起,导致每一行都扩展为多行。

我希望它始终在一行中显示文本,如下所示(OK):

但是有很多列会将文本换成两行或更多行(不行):

未定义列宽,因为它也会根据要显示的文本而变化。

无论用户选择多少列,我如何确保该行始终像 ex.1 一样单行?

我有这个JSFiddle demo 上面两个例子的代码:

<table class='table'>
    <thead>
        <tr>
            <th>Column 1</th>
            <th>Column 2</th>
            <th>Column 3</th>
            <th>Column 4</th>
            <th>Column 5</th>
            <th>Column 6</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Row 1</td>
            <td>Row 11</td>
            <td>Row 11 1</td>
            <td>Row 11 11</td>
            <td>Row 11 11 1</td>
            <td>Row 11 11 11</td>
        </tr>
        <tr>
            <td>Row 2</td>
            <td>Row 22</td>
            <td>Row 22 2</td>
            <td>Row 22 22</td>
            <td>Row 22 22 2</td>
            <td>Row 22 22 22</td>
        </tr>
    </tbody>
</table>

【问题讨论】:

    标签: jquery css twitter-bootstrap-3


    【解决方案1】:

    尝试将此 CSS 添加到您的表格元素中: white-space: nowrap jsFiddle

    【讨论】:

    • 这行得通 - 是否有合适的 Bootstrap 类?如果没有,我会在几天内接受这个答案。
    • 我给你100个赞!
    • 有一个引导类:text-nowrap
    • 谢谢。你救了我一天。
    猜你喜欢
    • 2017-08-20
    • 2021-04-07
    • 2018-05-17
    • 1970-01-01
    • 2022-11-12
    • 2016-06-29
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    相关资源
    最近更新 更多