2

I want to align: center the "select all" checkbox in the header. It is the first cell in the header of jqgrid.

I tried:

#configDiv th input[type="checkbox"] {
    margin: 0 auto !important;
}

and

grid.find('th input[type="checkbox"]').css("align", "center");

Those didn't work!

Any idea?

worldofjr
  • 3,868
  • 8
  • 37
  • 49
amanda chaw
  • 137
  • 2
  • 14

2 Answers2

2

Thanks to this answer from Oleg I found this;

grid.closest('div.ui-jqgrid-view').find('table.ui-jqgrid-htable th:first-child').css("text-align", "center");
Community
  • 1
  • 1
amanda chaw
  • 137
  • 2
  • 14
1

Inputs, such as checkboxes, are inline elements and you can't centre them directly. You need to centre the "text" (I know a checkbox isn't text, but that is what the CSS rule is) in the parent element, in this case the th.

You can do that with the following code in your CSS;

#configDiv th {
    text-align: center;
}

If you need to target the particular th then you should add a class to the HTML and use the th.classname selector.

Hope this helps.

worldofjr
  • 3,868
  • 8
  • 37
  • 49