2017-10-19 113 views
0

我在頁面上有一個表格,使用數據表格檢索和顯示內容。但是這些列不與中心對齊。這就是它現在的樣子。 Click Here 。這是我正在創建表Datatables align center

$(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> 
+0

你有沒有嘗試'文字對齊:中心;'? –

回答

0

定義數據表時,補充一點:

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

添加到你的CSS:

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

我在哪裏添加這個? Bootstrap CSS或Datatables CSS? –

+1

你添加到你自己的CSS,這是一個非常基本的問題,看看這個鏈接https://datatables.net/examples/index並研究數據表的基礎知識 – juntapao