css - 带有 Bootstrap 表响应的 DataTables 总是有小的 x 溢出

标签 css twitter-bootstrap datatables

我正在使用 DataTables 和 Bootstrap,但无论我有多少列,我的表上总是会出现一点 x-overflow。截图:

enter image description here

我的标记:

<div class="table-responsive">
    <table class="table data-table">
        <thead>
            ...
        </thead>
        <tbody>
            ...
        </tbody>
    </table>
</div>

我没有对 data-table 类应用任何样式,tabletable-responsive 类都是 Bootstrap 的。

我的初始化代码:

$('.data-table').DataTable();

如何消除这种不必要的 x 滚动?我希望它仅在屏幕小得多且列明显不适合时使用。

最佳答案

解决方案

您需要使用 container .使用 containercontainer-fluid 类将您的标记包装在 div 中。

<div class="container-fluid">
    <div class="table-responsive">
        <table class="table data-table">
            <thead>
                ...
            </thead>
            <tbody>
                ...
            </tbody>
        </table>
    </div>
</div>

同时添加以下 CSS 规则:

.table-responsive {
   overflow-x: inherit;
}

演示

参见 this jsFiddle用于代码和演示。

关于css - 带有 Bootstrap 表响应的 DataTables 总是有小的 x 溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33808714/

相关文章:

html - 将 float 导航元素保持在一行

css - Bootstrap 中针对不同屏幕尺寸的最小宽度

jQuery DataTables Ajax 调用不起作用

带有 AJAX 内容的 JQuery UI 选项卡使用 IE9 非常慢

javascript - 如何选择行数据表对应的页

html - 将居中的 Div 与紧靠右侧的 Div 对齐

css - 是否可以在 CSS 中使用 `text-decoration: underline;` 明确设置下划线文本的行高?

html - 如何创建比其容器大的 div 背景

html - 使用 .affix 时元素宽度错误

javascript - Angular uib-dropdown 上的键盘导航不起作用