How to center align datatables header

前端 未结 4 1914
渐次进展
渐次进展 2021-02-19 23:32

I\'m new to datatables. When I make table header, it\'s always left align. How can I set the header to center align? I\'ve read datatables.net/manual/styling/classes and datatab

4条回答
  •  灰色年华
    2021-02-20 00:25

    You might have forgotten after specifying the class, you need to add the following in CSS:

    .dt-head-center {text-align: center;}
    

    Also, if the class has not been added to the of the table, try adding the below CSS for generic stuff:

    thead, th {text-align: center;}
    
    /* OR */
    
    .table thead,
    .table th {text-align: center;}
    

    To make it specific to a particular table, you can give the table an id="tableID" and then in the CSS, you can do:

    #tableID thead,
    #tableID th {text-align: center;}
    

提交回复
热议问题