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

This time I have a simple question. Here there is my query results, showed in the web app using jQuery

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"}
    ]
  });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744641834a4585488.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>