【问题标题】:Datatables align center数据表居中对齐
【发布时间】:2017-10-19 23:05:05
【问题描述】:

我在页面上有一个表格,并使用数据表检索和显示内容。但列未与中心对齐。这就是它现在的样子。 Click Here .这就是我创建表格的方式

$(document).ready(function() {
manageMemberTable = $("#manageMemberTable").DataTable({


    "ajax": "php_actionsms/retrieve.php",
    "order": [[0,'desc']]
});

HTML代码:

<div class="container">
    <div class="row">
        <div class="col-md-12">

            <center><h1 class="page-header">TMTRO Iloilo <small>Accident Report Records</small> </h1></center>

            <div class="removeMessages"></div>
            <br /> <br /> <br />

            <table class="table table-responsive " id="manageMemberTable">                  
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Recipient</th>
                        <th>Recipient Number</th>
                        <th>Place</th>
                        <th>Officer</th>
                        <th>Date&Time</th>                                              
                        <th>Sent to Icer</th>
                        <th>Option</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>

【问题讨论】:

  • 你试过text-align:center; 吗?

标签: html datatables


【解决方案1】:

在定义数据表时添加:

"columnDefs": [
    {"className": "dt-center", "targets": "_all"}
]

将此添加到您的 CSS:

 th.dt-center, td.dt-center { text-align: center; }

【讨论】:

  • 我在哪里添加这个? Bootstrap CSS 还是 Datatables CSS?
  • 您将其添加到您自己的 CSS 中,这是一个非常基本的问题,请查看此链接 datatables.net/examples/index 并首先学习数据表的基础知识
猜你喜欢
  • 2016-10-29
  • 1970-01-01
  • 2012-12-13
  • 1970-01-01
  • 1970-01-01
  • 2015-07-25
  • 2016-12-09
  • 2018-05-12
  • 2017-01-16
相关资源
最近更新 更多