【问题标题】:datatable increase table search filter widthdatatable 增加表格搜索过滤器宽度
【发布时间】:2019-04-28 00:23:30
【问题描述】:

我想知道是否可以更改数据表搜索过滤器字段的宽度

我想把它的当前宽度加倍

<div class="table-responsive">
    <table class="table table-hover" id="myTable">
        <thead>
            <tr>
                <th scope="col">#</th>
                <th scope="col">Name</th>
                <th scope="col">Added by</th>
                <th scope="col">Added at</th>
                <th scope="col">Action</th>
            </tr>
        </thead>
        <tbody class="custom-tbody">
        <?php $n = 1; ?>
            @foreach ($authors as $item)
                <tr>
                    <th scope="row">{{ $n++ }}</th>
                    <td>{{ $item->name }}</td>
                    <td>{{ $item->user->username }}</td>
                    <td>{{ $item->created_at }}</td>
                    <td>
                        <a href="authors/{{ $item->id }}/edit" 
                            class="btn btn-primary">Edit
                        </a>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
</div>

这是我使用 laravel 的整个表格代码。 但我找不到“搜索过滤器字段”的 html 来增加它的宽度。 datatable.css 和 datatable.js 在我的公共文件夹中。

【问题讨论】:

  • 你试过我的答案了吗?

标签: jquery html laravel css datatables


【解决方案1】:

将此样式添加到您的 html 页面或 CSS 文件中。

.dataTables_filter input {
    width: 500px; 
}

根据您的要求修改宽度。

【讨论】:

  • 我试过了,但没有任何改变。即使在我“运行 npm dev”之后。
  • 尝试将您的示例代码放在 jsfiddle.net 中,我会更有帮助从社区获得答案。
【解决方案2】:

在 css/jquery.dataTables.css 文件中添加这个 css:

.dataTables_filter input {
    width: 450px !important; 
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-29
    • 2015-12-19
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    相关资源
    最近更新 更多