最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Center element in jQuery DataTable column cell - Stack Overflow

programmeradmin3浏览0评论

This time I have a simple question.

Here there is my query results, showed in the web app using jQuery Data Table:

As you can see, the elements are not centered inside the column cells. So, the question is: how can I show the elements, both numbers and buttons, centered?

This time I have a simple question.

Here there is my query results, showed in the web app using jQuery Data Table:

As you can see, the elements are not centered inside the column cells. So, the question is: how can I show the elements, both numbers and buttons, centered?

Share Improve this question asked Aug 9, 2017 at 9:38 Luca SepeLuca Sepe 8155 gold badges20 silver badges32 bronze badges 2
  • Can you post the html and css? – Thomas Orlita Commented Aug 9, 2017 at 9:39
  • text-align: center; Works also for your buttons. – Doomenik Commented Aug 9, 2017 at 9:41
Add a ment  | 

1 Answer 1

Reset to default 6

Add

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

to your css, or use Javascript

$(document).ready( function () {
   var table = $('#example').DataTable({
   "columnDefs": [
       {"className": "dt-center", "targets": "_all"}
    ]
  });
});
发布评论

评论列表(0)

  1. 暂无评论